soup-files 1.2.1__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
soup_files/__main__.py ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python3
2
+ from soup_files import __version__
3
+
4
+ def test():
5
+ from soup_files import File, Directory, UserFileSystem, LibraryDocs, InputFiles
6
+ pass
7
+
8
+
9
+ def main():
10
+ print(f' soup_files - versão: {__version__}')
11
+ test()
12
+
13
+ if __name__ == '__main__':
14
+ main()
soup_files/files.py CHANGED
@@ -190,12 +190,13 @@ class Directory(object):
190
190
  return values
191
191
 
192
192
  def __content_no_recursive(self) -> List[File]:
193
- files = os.listdir(self.absolute())
193
+ content_files: List[str] = os.listdir(self.absolute())
194
194
  values: List[File] = []
195
- for f in files:
196
- if os.path.isfile(f):
195
+ for file in content_files:
196
+ fp: str = os.path.join(self.absolute(), file)
197
+ if os.path.isfile(fp):
197
198
  values.append(
198
- File(os.path.abspath(f))
199
+ File(os.path.abspath(fp))
199
200
  )
200
201
  return values
201
202
 
@@ -216,9 +217,10 @@ class Directory(object):
216
217
  else:
217
218
  _paths = os.listdir(self.absolute())
218
219
  for d in _paths:
219
- if os.path.isdir(d):
220
+ _dirpath = os.path.join(self.absolute(), d)
221
+ if os.path.isdir(_dirpath):
220
222
  values.append(
221
- Directory(os.path.abspath(d))
223
+ Directory(os.path.abspath(_dirpath))
222
224
  )
223
225
  return values
224
226
 
@@ -285,7 +287,6 @@ class InputFiles(object):
285
287
  return content_files
286
288
 
287
289
  def __get_files_recursive(self, *, file_type: LibraryDocs, sort: bool) -> List[File]:
288
- #
289
290
  #
290
291
  _paths: List[Path] = self.input_dir.iterpaths()
291
292
  _all_files = []
@@ -319,33 +320,25 @@ class InputFiles(object):
319
320
  _all_files.sort(key=File.absolute)
320
321
  return _all_files
321
322
 
322
- def __get_files_no_recursive(self, *, file_type: LibraryDocs, sort: bool):
323
- _paths: List[str] = os.listdir(self.input_dir.absolute())
324
- _all_files = []
323
+ def __get_files_no_recursive(self, *, file_type: LibraryDocs, sort: bool) -> List[File]:
324
+ _content_files: List[File] = self.input_dir.content_files(recursive=False)
325
+
326
+ _all_files: List[File] = []
325
327
  count: int = 0
326
328
  if file_type == LibraryDocs.ALL:
327
329
  # Todos os tipos de arquivos
328
- for p in _paths:
329
- if os.path.isfile(p):
330
- _all_files.append(
331
- File(os.path.abspath(p))
332
- )
333
- count += 1
334
- if count >= self.maxFiles:
335
- break
330
+ for file in _content_files:
331
+ _all_files.append(file)
332
+ count += 1
333
+ if count == self.maxFiles:
334
+ break
336
335
  else:
337
336
  # Arquivos especificados em LibraryDocs
338
- for p in _paths:
339
- if os.path.isfile(p):
340
- _path_file = Path(p)
341
- if (_path_file.suffix is None) or (_path_file.suffix == ''):
342
- continue
343
- if _path_file.suffix in file_type.value:
344
- _all_files.append(
345
- File(os.path.abspath(_path_file.absolute()))
346
- )
347
- count += 1
348
- if count >= self.maxFiles:
337
+ for file in _content_files:
338
+ if file.extension() in file_type.value:
339
+ _all_files.append(file)
340
+ count += 1
341
+ if count == self.maxFiles:
349
342
  break
350
343
  if sort:
351
344
  _all_files.sort(key=File.absolute)
@@ -366,9 +359,8 @@ class InputFiles(object):
366
359
 
367
360
  """
368
361
  if recursive:
369
- return self.__get_files_recursive(file_type=file_type, sort=sort)
370
- else:
371
- return self.__get_files_no_recursive(file_type=file_type, sort=sort)
362
+ return self.__get_files_recursive(file_type=file_type, sort=sort)
363
+ return self.__get_files_no_recursive(file_type=file_type, sort=sort)
372
364
 
373
365
 
374
366
  class JsonData(object):
@@ -451,13 +443,8 @@ class UserFileSystem(object):
451
443
  """
452
444
  Diretórios comuns para cache e configurações de usuário.
453
445
  """
454
- def __init__(self, base_home:Directory=None):
455
- if base_home is None:
456
- self.baseHome:Directory = Directory(os.path.abspath(Path().home()))
457
- elif isinstance(base_home, Directory):
458
- self.baseHome:Directory = base_home
459
- else:
460
- raise ValueError(f'{__class__.__name__}\nUse:Directory(), não {type(base_home)}')
446
+ def __init__(self, base_home: Directory = Directory(os.path.abspath(Path().home()))):
447
+ self.baseHome:Directory = base_home
461
448
  self.userDownloads:Directory = self.baseHome.concat('Downloads', create=True)
462
449
  self.userVarDir:Directory = self.baseHome.concat('var', create=True)
463
450
 
@@ -472,11 +459,11 @@ class UserAppDir(object):
472
459
  """
473
460
  Diretório comun para cache e configurações do aplicativo.
474
461
  """
475
- def __init__(self, appname:str, *, user_file_system:UserFileSystem=UserFileSystem()):
462
+ def __init__(self, appname:str, *, user_file_system: UserFileSystem = UserFileSystem()):
476
463
  self.appname = appname
477
- self.userFileSystem:UserFileSystem = user_file_system
478
- self.workspaceDirApp:Directory = self.userFileSystem.userDownloads.concat(self.appname, create=True)
479
- self.installDir:Directory = self.userFileSystem.userVarDir.concat('opt').concat(self.appname, create=True)
464
+ self.userFileSystem: UserFileSystem = user_file_system
465
+ self.workspaceDirApp: Directory = self.userFileSystem.userDownloads.concat(self.appname, create=True)
466
+ self.installDir: Directory = self.userFileSystem.userVarDir.concat('opt').concat(self.appname, create=True)
480
467
 
481
468
  def cache_dir_app(self) -> Directory:
482
469
  return self.userFileSystem.cache_dir().concat(self.appname, create=True)
soup_files/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
- __version__ = '1.2.1'
3
+ __version__ = '1.2.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soup_files
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: soup_files
5
5
  Author: Bruno Chaves
6
6
  Requires-Python: >=3.11
@@ -0,0 +1,9 @@
1
+ soup_files/__init__.py,sha256=G91WhdwJvUJJLiIDL2XSGSqZNwLoJ7gfLfiYquUkNpk,299
2
+ soup_files/__main__.py,sha256=4n2EX5vpzi23kXwofvCzQirZI8kRYDT7LYgLlb6bK1E,282
3
+ soup_files/files.py,sha256=lGJlh4JIuYjLcSNfgk7h6t36yp6wPO0Q1pVZ7F0_Q6Y,15354
4
+ soup_files/progress.py,sha256=kGPESPQCmoIlgJoy7Y8sF5ZG9tfx6uafXYrcBAPibfY,2903
5
+ soup_files/version.py,sha256=uEbUu3tUCXHsVQ_A4NejisFTCeRZeOBepKbXH7WD88c,46
6
+ soup_files-1.2.2.dist-info/METADATA,sha256=93hcC54kweMypQit8HA5U21np6TgdcMf9PScfa8_l1I,174
7
+ soup_files-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ soup_files-1.2.2.dist-info/top_level.txt,sha256=CBSaCdIqL_Rlkr74APmmI0kXkPK9pVf6HTlOPZ-Kk4E,11
9
+ soup_files-1.2.2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- soup_files/__init__.py,sha256=G91WhdwJvUJJLiIDL2XSGSqZNwLoJ7gfLfiYquUkNpk,299
2
- soup_files/files.py,sha256=QN29DUXrQtqS_wI_KawqUB0XCyjnzH4cgyolaXdkg04,15784
3
- soup_files/progress.py,sha256=kGPESPQCmoIlgJoy7Y8sF5ZG9tfx6uafXYrcBAPibfY,2903
4
- soup_files/version.py,sha256=TpmZmL9rNerchvGdpdGh4bPNo516cs6BzzXctjsbRq8,46
5
- soup_files-1.2.1.dist-info/METADATA,sha256=jqN1cgUQJGoi-kCfi2aU901x6o1af2lIwmr5vti9s54,174
6
- soup_files-1.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- soup_files-1.2.1.dist-info/top_level.txt,sha256=CBSaCdIqL_Rlkr74APmmI0kXkPK9pVf6HTlOPZ-Kk4E,11
8
- soup_files-1.2.1.dist-info/RECORD,,