Skip to content

Sourcery refactored 1.0.6 branch#2

Open
sourcery-ai[bot] wants to merge 1 commit into1.0.6from
sourcery/1.0.6
Open

Sourcery refactored 1.0.6 branch#2
sourcery-ai[bot] wants to merge 1 commit into1.0.6from
sourcery/1.0.6

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot commented May 20, 2022

Branch 1.0.6 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the 1.0.6 branch, then run:

git fetch origin sourcery/1.0.6
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from luxuncang May 20, 2022 06:08
Comment thread HTTPengine.py
'''`engine.requests` 为 `requests` 请求接口'''
res = requests.request(*self.args, **self.kw)
return res
return requests.request(*self.args, **self.kw)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function engine.requests refactored with the following changes:

Comment thread HTTPengine.py
Comment on lines -36 to +35
res = requests.request(*self.args, **self.kw)
return res
return requests.request(*self.args, **self.kw)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function engine.httpx refactored with the following changes:

Comment thread HTTPengine.py
Comment on lines -87 to +89
if not 'headers' in self.kw:
if 'headers' not in self.kw:
self.kw['headers'] = {'User-Agent' : get_header()}
elif not 'User-Agent' in self.kw['headers']:
elif 'User-Agent' not in self.kw['headers']:
self.kw['headers'].update({'User-Agent' : get_header()})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lupro.__init__ refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment thread HTTPengine.py
Comment on lines -139 to +141
if not res.status_code == 200:
if res.status_code != 200:
return ask(self)
if len(res.content) < self.content:
return ask(self)
print(logging(f"{self.filename} {len(res.content)} -----> 请求结束!"))
print(logging(f"{self.filename} {len(res.content)} -----> 请求结束!"))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lupro.task.ask refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment thread HTTPengine.py
Comment on lines -224 to +223
path = os.path.join(path,os.path.split(self.filename)[1]+f'.{self.format}')
if res.apparent_encoding == None:
path = os.path.join(path, f'{os.path.split(self.filename)[1]}.{self.format}')
if res.apparent_encoding is None:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lupro.save_file refactored with the following changes:

Comment thread hooks.py
Comment on lines -11 to +16
def __getattr__(cls, name):
if not '__general__' in dir(cls):
def __getattr__(self, name):
if '__general__' not in dir(self):
raise NameError("name '__general__' is not defined")
if hasattr(cls.__general__, name):
return getattr(cls.__general__, name)
raise AttributeError(f"method '{name}' is not defined in {cls.__general__}")
if hasattr(self.__general__, name):
return getattr(self.__general__, name)
raise AttributeError(f"method '{name}' is not defined in {self.__general__}")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function inherit.__getattr__ refactored with the following changes:

Comment thread hooks.py
Comment on lines -22 to +23
def __repr__(cls) -> str:
return f"<lupros.{cls.__name__} object>"
def __repr__(self) -> str:
return f"<lupros.{self.__name__} object>"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function repr.__repr__ refactored with the following changes:

Comment thread publictool.py
Comment on lines -13 to +17
def __getattr__(cls, name):
if not '__general__' in dir(cls):
def __getattr__(self, name):
if '__general__' not in dir(self):
raise NameError("name '__general__' is not defined")
if hasattr(cls.__general__, name):
return getattr(cls.__general__, name)
if hasattr(self.__general__, name):
return getattr(self.__general__, name)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function inherit.__getattr__ refactored with the following changes:

Comment thread publictool.py

with shelve.open(persistence.shelve.dbfile) as f:
res = {i:j for i,j in f.items()}
res = dict(f.items())
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function persistence.shelve.put refactored with the following changes:

Comment thread publictool.py
return func(*args , **kwargs)
else:
return None
return func(*args , **kwargs) if config else None
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reconfig refactored with the following changes:

Comment thread publictool.py
Comment on lines -127 to +124
if value:
return value
else:
return default
return value or default
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function putdefault refactored with the following changes:

Comment thread publictool.py
Comment on lines -134 to +138
if response.apparent_encoding == None:
if response.apparent_encoding is None:
return bytescoding(response.content)
else:
response.encoding = response.apparent_encoding
return response.content.decode(response.encoding, 'ignore') No newline at end of file
response.encoding = response.apparent_encoding
return response.content.decode(response.encoding, 'ignore') No newline at end of file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function responsecoding refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants