py2ls 0.1.6.6__py3-none-any.whl → 0.1.6.7__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.
@@ -1,33 +1,71 @@
1
1
  import os
2
2
  from datetime import datetime
3
3
  import subprocess
4
+ import re
4
5
 
5
- def export_requirements(fpath="/Users/macjianfeng/Dropbox/github/python/py2ls/"):
6
+ def export_requirements(fpath="/Users/macjianfeng/Dropbox/github/python/py2ls/", exclude=["py2ls","jaraco"]):
6
7
  """
7
8
  Main function to generate a timestamped requirements file and convert it to Poetry dependencies.
8
9
  """
9
-
10
- current_time = datetime.now().strftime("%Y-%m-%d_%H_%M_%S")
11
- fpath_requirements = f"{fpath}{current_time}_requirements.txt"
12
- print("Current date and time:", current_time)
10
+ if not fpath.endswith('/'):
11
+ fpath+='/'
12
+ with open(os.path.join(fpath,'pyproject.toml'),'r') as f:
13
+ txt=f.read()
14
+ txt_list = re.split('\n',txt)
15
+
16
+ idx_start=[i for i,item in enumerate(txt_list) if item.startswith('[tool.poetry.dependencies]')][0]+2
17
+ idx_stop=[i for i,item in enumerate(txt_list) if item.startswith('[build-system]')][0]
18
+
19
+ # keep the head info
20
+ txt_list_head=txt_list[:idx_start]
21
+ txt_list_tail=txt_list[idx_stop:]
22
+
23
+ # keep the tail info
24
+ txt_list_head=[i+"\n" for i in txt_list_head]
25
+ txt_list_tail=[i+"\n" for i in txt_list_tail]
26
+
27
+ # filename
28
+ current_time = datetime.now().strftime("%Y-%m-%d")
29
+ fpath_requirements = f"{fpath}requirements_{current_time}.txt"
13
30
 
14
31
  os.makedirs(os.path.dirname(fpath_requirements), exist_ok=True)
15
32
 
33
+ # get the updated requirements.txt
16
34
  try:
17
35
  with open(fpath_requirements, 'w') as requirements_file:
18
36
  subprocess.run(['pip', 'freeze'], stdout=requirements_file, check=True)
19
37
  print(f"Requirements have been saved to {fpath_requirements}")
20
38
  except subprocess.CalledProcessError as e:
21
39
  print(f"An error occurred while creating the requirements file: {e}")
40
+
41
+ # open the orgi toml file
42
+ try:
43
+ with open(fpath_requirements, 'r') as file:
44
+ txt = file.read()
45
+ except Exception as e:
46
+ print(f"An error occurred while reading the requirements file: {e}")
47
+
48
+ # convert to poetry
22
49
  txt_corr=[]
23
50
  for txt_ in re.split('\n', txt):
24
- if len(txt_) <=40:
51
+ if len(txt_) <=40 and not txt_=='':
25
52
  txt_corr.append(txt_.replace("==",' = "^')+'"\n')
26
- with open(fpath_requirements.replace('requirements.txt','for_poetry.txt'), 'w') as f:
27
- f.writelines(txt_corr)
53
+
54
+ # add a newline
55
+ txt_corr.append('\n')
56
+
57
+ # merge
58
+ txt_corr_=[*txt_list_head, *txt_corr, *txt_list_tail]
59
+
60
+ # rm .txt
61
+ # os.remove(fpath_requirements)
62
+
63
+ # fsave
64
+ with open(f"{fpath}pyproject_{current_time}.toml", 'w') as f:
65
+ f.writelines(txt_corr_)
28
66
 
29
67
  def main():
30
- export_requirements(fpath="/Users/macjianfeng/Dropbox/github/python/py2ls/")
68
+ export_requirements(fpath="/Users/macjianfeng/Dropbox/github/python/py2ls/")
31
69
 
32
70
  if __name__ == "__main__":
33
71
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.1.6.6
3
+ Version: 0.1.6.7
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com
@@ -132,7 +132,7 @@ py2ls/data/docs_links.json,sha256=kXgbbWo0b8bfV4n6iuuUNLnZipIyLzokUO6Lzmf7nO4,10
132
132
  py2ls/data/lang_code_iso639.json,sha256=qZiU7H2RLJjDMXK22C-jhwzLJCI5vKmampjB1ys4ek4,2157
133
133
  py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
134
134
  py2ls/doc.py,sha256=xN3g1OWfoaGUhikbJ0NqbN5eKy1VZVvWwRlhHMgyVEc,4243
135
- py2ls/export_requirements.py,sha256=qsyYrT_fnBlaMuWRYr3EnDyAKT52yJJBlW0Em_rlvrU,1265
135
+ py2ls/export_requirements.py,sha256=psZtSe-MOD9L_w3dVpA_VJEKfq3J914g3Y1OtRNAb4g,2324
136
136
  py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
137
137
  py2ls/ips.py,sha256=B88jol_EYZ4IERWAeabkHSwMkGytqyBheEbbpM_YDiQ,86146
138
138
  py2ls/netfinder.py,sha256=ZsLWGYMeRuGvxj2nqE0Z8ANoaVl18Necfw0HQfh2q7I,45548
@@ -142,6 +142,6 @@ py2ls/sleep_events_detectors.py,sha256=36MCuRrpurn0Uvzpo3p3b3_JlVsRNHSWCXbJxCGM3
142
142
  py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
143
143
  py2ls/translator.py,sha256=6S7MmTZmjj8NljVmj0W5uEauu4ePxso3AMf2LvGVRQA,30516
144
144
  py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
145
- py2ls-0.1.6.6.dist-info/METADATA,sha256=L7E5_PaUNRXQzUiwKTqHFTNjDPSA7iUu_wCYOs6SHHE,20998
146
- py2ls-0.1.6.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
147
- py2ls-0.1.6.6.dist-info/RECORD,,
145
+ py2ls-0.1.6.7.dist-info/METADATA,sha256=-gKMv_eCD4spLGvNAidRLyfI07hf1eq_ldQsfFmxlsA,20998
146
+ py2ls-0.1.6.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
147
+ py2ls-0.1.6.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any