Mercurial > hg
comparison mercurial/util.py @ 43920:4222b9d5d4fb
util: move common proxyobserver attributes to the base class
Fixes the following pytype warnings:
line 791, in _writedata: No attribute 'logdata' on baseproxyobserver [attribute-error]
line 792, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
line 793, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 794, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 799, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
line 800, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 802, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 803, in _writedata: No attribute 'name' on baseproxyobserver [attribute-error]
line 805, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 809, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
line 810, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 814, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
line 815, in _writedata: No attribute 'name' on baseproxyobserver [attribute-error]
line 817, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
Differential Revision: https://phab.mercurial-scm.org/D7675
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 15 Dec 2019 21:34:00 -0500 |
parents | 68af0228fedc |
children | f9d29e1d3354 |
comparison
equal
deleted
inserted
replaced
43919:6b6872822b32 | 43920:4222b9d5d4fb |
---|---|
785 'setsockopt', *args, **kwargs | 785 'setsockopt', *args, **kwargs |
786 ) | 786 ) |
787 | 787 |
788 | 788 |
789 class baseproxyobserver(object): | 789 class baseproxyobserver(object): |
790 def __init__(self, fh, name, logdata, logdataapis): | |
791 self.fh = fh | |
792 self.name = name | |
793 self.logdata = logdata | |
794 self.logdataapis = logdataapis | |
795 | |
790 def _writedata(self, data): | 796 def _writedata(self, data): |
791 if not self.logdata: | 797 if not self.logdata: |
792 if self.logdataapis: | 798 if self.logdataapis: |
793 self.fh.write(b'\n') | 799 self.fh.write(b'\n') |
794 self.fh.flush() | 800 self.fh.flush() |
821 """Logs file object activity.""" | 827 """Logs file object activity.""" |
822 | 828 |
823 def __init__( | 829 def __init__( |
824 self, fh, name, reads=True, writes=True, logdata=False, logdataapis=True | 830 self, fh, name, reads=True, writes=True, logdata=False, logdataapis=True |
825 ): | 831 ): |
826 self.fh = fh | 832 super(fileobjectobserver, self).__init__(fh, name, logdata, logdataapis) |
827 self.name = name | |
828 self.logdata = logdata | |
829 self.logdataapis = logdataapis | |
830 self.reads = reads | 833 self.reads = reads |
831 self.writes = writes | 834 self.writes = writes |
832 | 835 |
833 def read(self, res, size=-1): | 836 def read(self, res, size=-1): |
834 if not self.reads: | 837 if not self.reads: |
947 writes=True, | 950 writes=True, |
948 states=True, | 951 states=True, |
949 logdata=False, | 952 logdata=False, |
950 logdataapis=True, | 953 logdataapis=True, |
951 ): | 954 ): |
952 self.fh = fh | 955 super(socketobserver, self).__init__(fh, name, logdata, logdataapis) |
953 self.name = name | |
954 self.reads = reads | 956 self.reads = reads |
955 self.writes = writes | 957 self.writes = writes |
956 self.states = states | 958 self.states = states |
957 self.logdata = logdata | |
958 self.logdataapis = logdataapis | |
959 | 959 |
960 def makefile(self, res, mode=None, bufsize=None): | 960 def makefile(self, res, mode=None, bufsize=None): |
961 if not self.states: | 961 if not self.states: |
962 return | 962 return |
963 | 963 |