bcpkgfox 0.16.35__tar.gz → 0.16.37__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.16.35
3
+ Version: 0.16.37
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: Guilherme Neri
@@ -59,7 +59,9 @@ class cli:
59
59
 
60
60
  venv_group.add_argument(
61
61
  '-r', '--requirements',
62
- action='store_true',
62
+ nargs='?',
63
+ action=self.venv_manager.custom_action_requirements,
64
+ default=False,
63
65
  help="Create a requirements\n"
64
66
  )
65
67
 
@@ -182,6 +184,10 @@ class cli:
182
184
  print(f"{self.visuals.bold}{self.visuals.RD} > Error: You need to use one function that installs imports before verifying them{self.visuals.RESET}")
183
185
  print("\033[J", end='', flush=True)
184
186
 
187
+ # Requirements
188
+ if self.args.requirements:
189
+ self.venv_manager.requirements()
190
+
185
191
  self.clean_terminal()
186
192
 
187
193
  def clean_terminal(self):
@@ -794,21 +800,43 @@ class cli:
794
800
  self.delete_venv()
795
801
  self.create_venv()
796
802
 
797
- def requirementes(self):
798
- if self.cli.args.requirements:
799
- if '.' in self.cli.args.requirements:
800
- ext = self.cli.args.requirements.rsplit('.', 1)[1]
803
+ class custom_action_requirements(argparse.Action):
804
+ ''' This is necessary to define a new action and the parser identifies it as valid '''
805
+
806
+ def __call__(self, parser, namespace, values, option_string=None):
807
+ if values is None:
808
+ setattr(namespace, self.dest, 'requirements.txt')
801
809
  else:
802
- ext = None
803
- try:
804
- os.remove(os.path.join(self.current_dir, self.cli.args.requirements))
805
- except:
806
- try:
807
- os.remove(os.path.join(self.current_dir, 'requirements.txt'))
808
- except:
809
- pass
810
+ setattr(namespace, self.dest, values)
810
811
 
811
- subprocess.run("pip freeze > requirements.txt", shell=True)
812
+ def requirements(self):
813
+
814
+ # Identifies endwish
815
+ if '.' in self.cli.args.requirements:
816
+ name = self.cli.args.requirements
817
+ else:
818
+ name = self.cli.args.requirements + '.txt'
819
+
820
+ # Attempt of recreate
821
+ try:
822
+ os.remove(os.path.join(self.current_dir, name))
823
+ except:
824
+ pass
825
+
826
+ # Creates a new one
827
+ subprocess.run(f"pip freeze > {name}", shell=True)
828
+
829
+ # Read
830
+ with open(f'{name}', 'r') as f:
831
+ lines = f.readlines()
832
+
833
+ # Re-write
834
+ imports = self.cli.find_import.main(return_=True)
835
+ imports_lower = {imp.lower() for imp in imports}
836
+ with open(f'{name}', 'w') as f:
837
+ for line in lines:
838
+ if line.lower() in imports_lower:
839
+ f.write(line)
812
840
 
813
841
  def main(self):
814
842
  try: self.delete_venv()
@@ -253,5 +253,3 @@ class System:
253
253
  return estados[valor.upper()]
254
254
  estado_uf = {v.lower(): k for k, v in estados.items()}
255
255
  return estado_uf.get(valor.lower(), "Valor inválido")
256
-
257
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.16.35
3
+ Version: 0.16.37
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: Guilherme Neri
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="bcpkgfox",
5
- version="0.16.35",
5
+ version="0.16.37",
6
6
  author="Guilherme Neri",
7
7
  author_email="guilherme.neri@bcfox.com.br",
8
8
  description="Biblioteca BCFOX",
File without changes
File without changes
File without changes