Skip to main content
deleted 19 characters in body
Source Link
Ludisposed
  • 11.8k
  • 2
  • 41
  • 91

This is decent code, job well done!

I have a few nitpicks,

  • PEP8 violations
  1. Functions and variables should be snake_case
  2. Group your imports

There are multiple tools out there that checks your code PEP8, when your IDE does not support it violations

  • When joining paths => us pathlib or os.path.join

Adding paths via string concatenations can be error prone, it is best to use os.path.join(path1, path2)

For instance it will handle cases when you try to add /a/b/ with /c/d

You do this in a few placeplaces, but not all the time. Stay consistent!

  • extention = filename.rsplit(".")[1]

You can use root, extentsion = os.path.splittext(filename)

  • You can catch multiple exceptions at once

     except (pmko.ssh_exception.NoValidConnectionsError, TimeoutError): 
  • Instead of printing what went wrong, try logging

Print statements are there for a short time, logs are forever

  • if not bool(re.search(r'\_c\.', _file)):

Here bool is superfluous when no match is found it will return None, which is FalsyFalsey

This is decent code, job well done!

I have a few nitpicks,

  • PEP8 violations
  1. Functions and variables should be snake_case
  2. Group your imports

There are multiple tools out there that checks your PEP8, when your IDE does not support it

  • When joining paths => us pathlib or os.path.join

Adding paths via string concatenations can be error prone, it is best to use os.path.join(path1, path2)

For instance it will handle cases when you try to add /a/b/ with /c/d

You do this in a few place, but not all the time. Stay consistent!

  • extention = filename.rsplit(".")[1]

You can use root, extentsion = os.path.splittext(filename)

  • You can catch multiple exceptions at once

     except (pmko.ssh_exception.NoValidConnectionsError, TimeoutError): 
  • Instead of printing what went wrong, try logging

Print statements are there for a short time, logs are forever

  • if not bool(re.search(r'\_c\.', _file)):

Here bool is superfluous when no match is found it will return None, which is Falsy

This is decent code, job well done!

I have a few nitpicks,

  • PEP8 violations
  1. Functions and variables should be snake_case
  2. Group your imports

There are multiple tools out there that checks your code PEP8 violations

  • When joining paths => us pathlib or os.path.join

Adding paths via string concatenations can be error prone, it is best to use os.path.join(path1, path2)

For instance it will handle cases when you try to add /a/b/ with /c/d

You do this in a few places, but not all the time. Stay consistent!

  • extention = filename.rsplit(".")[1]

You can use root, extentsion = os.path.splittext(filename)

  • You can catch multiple exceptions at once

     except (pmko.ssh_exception.NoValidConnectionsError, TimeoutError): 
  • Instead of printing what went wrong, try logging

Print statements are there for a short time, logs are forever

  • if not bool(re.search(r'\_c\.', _file)):

Here bool is superfluous when no match is found it will return None, which is Falsey

Source Link
Ludisposed
  • 11.8k
  • 2
  • 41
  • 91

This is decent code, job well done!

I have a few nitpicks,

  • PEP8 violations
  1. Functions and variables should be snake_case
  2. Group your imports

There are multiple tools out there that checks your PEP8, when your IDE does not support it

  • When joining paths => us pathlib or os.path.join

Adding paths via string concatenations can be error prone, it is best to use os.path.join(path1, path2)

For instance it will handle cases when you try to add /a/b/ with /c/d

You do this in a few place, but not all the time. Stay consistent!

  • extention = filename.rsplit(".")[1]

You can use root, extentsion = os.path.splittext(filename)

  • You can catch multiple exceptions at once

     except (pmko.ssh_exception.NoValidConnectionsError, TimeoutError): 
  • Instead of printing what went wrong, try logging

Print statements are there for a short time, logs are forever

  • if not bool(re.search(r'\_c\.', _file)):

Here bool is superfluous when no match is found it will return None, which is Falsy