ipyvasp 0.7.9__py2.py3-none-any.whl → 0.8.0__py2.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.
ipyvasp/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.7.9"
1
+ __version__ = "0.8.0"
ipyvasp/cli.py CHANGED
@@ -112,14 +112,16 @@ def _get_E0(files: List[Path]):
112
112
  def _set_dir(
113
113
  paths: List[Path], command: Annotated[str, typer.Option("-c", "--command")] = "",
114
114
  ignore_error: Annotated[bool, typer.Option("-i", "--ignore-error")] = False,
115
- time_interval: Annotated[int, typer.Option("-t",'--time-interval')] = 0
115
+ time_interval: Annotated[int, typer.Option("-t",'--time-interval')] = 0,
116
+ extra_command: Annotated[str, typer.Option("-e", "--extra-command")] = "",
116
117
  ):
117
118
  """Set multiple directories like a for loop to execute a shell command within each of them.
118
119
  It will raise an error if the command fails in any of the directories.
119
120
  To ignore the error and keep running in other directiories in sequence, use -i/--ignore-error.
120
121
  It will raise the shell errors but python will go through all the directories.
121
122
 
122
- To keep repeating a command after some time interval, use -t/--time-interval (seconds). Only works for a command
123
+ To keep repeating a command after some time interval, use -t/--time-interval (seconds). Only works for a command.
124
+ Use -e/--extra-command to run (in pwd) before looping over directories. This can be used to cleanup (previous results etc.) with each time recursion.
123
125
 
124
126
  Examples:
125
127
 
@@ -143,30 +145,43 @@ def _set_dir(
143
145
 
144
146
  abs_paths = [f.absolute() for f in dirs] # absolute path is must but after filtering
145
147
 
146
- def run(abs_paths, dirs, command, ignore_error):
148
+ def exec_cmd(command, path, ignore_error=ignore_error):
149
+ if command:
150
+ if os == "Windows":
151
+ try:
152
+ p = Popen("pwsh.exe -NoProfile -c " + command, shell=False)
153
+ except:
154
+ p = Popen("powershell.exe -NoProfile -c " + command, shell=False)
155
+
156
+ else:
157
+ p = Popen(command, shell=True) # Linux, MacOS, shell to get args
158
+
159
+ p.wait()
160
+ if not ignore_error and p.returncode != 0:
161
+ raise RuntimeError(f"Command {command} failed in {path}. Exiting...\n" +
162
+ "Use -i or --ignore-error switch to suppress error and continue in other directories silently."
163
+ )
164
+
165
+ def run(abs_paths, dirs, command, ec=extra_command):
166
+ if ec:
167
+ exec_cmd(ec, Path('.').absolute())
168
+ print(color.bb("\n"+f" {command} ".center(80,"-")))
169
+
147
170
  for path, d in zip(abs_paths,dirs):
148
171
  with set_dir(path):
149
172
  print(color.gb(f"📁 {str(d)!r}"))
150
-
151
- if command:
152
- if os == "Windows":
153
- try:
154
- p = Popen("pwsh.exe -NoProfile -c " + command, shell=False)
155
- except:
156
- p = Popen("powershell.exe -NoProfile -c " + command, shell=False)
157
-
158
- else:
159
- p = Popen(command, shell=True) # Linux, MacOS, shell to get args
160
-
161
- p.wait()
162
- if not ignore_error and p.returncode != 0:
163
- raise RuntimeError(f"Command {command} failed in {path}. Exiting...\n" +
164
- "Use -i or --ignore-error switch to suppress error and continue in other directories silently."
165
- )
166
-
173
+ exec_cmd(command, path)
174
+
167
175
  if time_interval > 0 and command: # repeat only if command given
168
176
  while True: # keep going until interrupted
169
- run(abs_paths, dirs, command, ignore_error)
177
+ run(abs_paths, dirs, command)
170
178
  sleep(time_interval)
171
179
  else:
172
- run(abs_paths, dirs, command, ignore_error)
180
+ run(abs_paths, dirs, command)
181
+
182
+ @app.command('get-bib')
183
+ def _get_bib(doi: List[str]):
184
+ "Get bibliography entries from doi. Can provide many DOIs."
185
+ from .misc import get_bib
186
+ for d in doi: # all of them
187
+ print(get_bib(d))
ipyvasp/misc.py CHANGED
@@ -1,5 +1,6 @@
1
- __all__ = ["parse_text", "get_E0", "OUTCAR"]
1
+ __all__ = ["parse_text", "get_bib", "get_E0", "OUTCAR"]
2
2
 
3
+ import requests
3
4
  from pathlib import Path
4
5
  from itertools import islice
5
6
 
@@ -24,6 +25,16 @@ def parse_text(path, shape, slice, **kwargs):
24
25
  ) # should be under open file context
25
26
  return data
26
27
 
28
+ def get_bib(DOI):
29
+ "Get bibligraphy entry from DOI"
30
+ response = requests.get(
31
+ f'http://dx.doi.org/{DOI}',
32
+ headers={'Accept':'text/bibliography;style=bibtex'})
33
+ if response.status_code == 200:
34
+ return response.content.decode('utf-8')
35
+
36
+ return response.status_code
37
+
27
38
  def get_E0(path: Path = 'OSZICAR'):
28
39
  "Get the E0 from the last line of OSZICAR."
29
40
  fh = Path(path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 0.7.9
3
+ Version: 0.8.0
4
4
  Summary: A processing tool for VASP DFT input/output processing in Jupyter Notebook.
5
5
  Home-page: https://github.com/massgh/ipyvasp
6
6
  Author: Abdul Saboor
@@ -2,12 +2,12 @@ ipyvasp/__init__.py,sha256=7o41i5eYlNKg1Hsv0DLNFZ81GilxB02IXAJN-QiJQi0,1420
2
2
  ipyvasp/__main__.py,sha256=eJV1TZSiT8mC_VqAeksNnBI2I8mKMiPkEIlwikbtOjI,216
3
3
  ipyvasp/_enplots.py,sha256=D38paN8zqZgluNAwmCwcocd7-_h_T0HTGolI1eBkDes,37484
4
4
  ipyvasp/_lattice.py,sha256=qLriOuitOFLghkj5qm-7JCMKUiJ2OFFBHKSEEEwLFvE,101176
5
- ipyvasp/_version.py,sha256=2COuLKlCBvCewCI1JpvBMfQZ3hPndyhZ1u6-3iIFqAM,23
5
+ ipyvasp/_version.py,sha256=QnzCBx4WS_Us0jMXCTUyXxzRhO9sLcwYv4ennXr7MSg,23
6
6
  ipyvasp/bsdos.py,sha256=kmVs-3LWnJ34WjoTZ5o8_VlKkuJFk5stcKLuW3p6azk,30217
7
- ipyvasp/cli.py,sha256=JuLrZ-3pnvhZQMExMsmUvnUpuFGeC_nkP2KpNXd_-R0,6276
7
+ ipyvasp/cli.py,sha256=aWFEVhNmnW8eSOp5uh95JaDwLQ9K9nlCQcbnOSuhWgw,6844
8
8
  ipyvasp/evals_dataframe.py,sha256=-sqxK7LPV6sYDO_XXmZ80FznOaXTkVdbqJKKvTUtMak,20637
9
9
  ipyvasp/lattice.py,sha256=FS8S1EzbOuIsbY7nUyBmt7wJOKdM54PgAnH2sIoKYms,24232
10
- ipyvasp/misc.py,sha256=OwmGlVR2JJg2EVbxe48Ax-6htP4Z56dE1rxbxo77qlE,2007
10
+ ipyvasp/misc.py,sha256=SZJ_ePUR2-HEKYTEpDHVRVE7zpIQVTCjiuw0BCC9UTU,2349
11
11
  ipyvasp/potential.py,sha256=tzA73c5lkp6ahLSJchMrU043-QWaOV0nIOUA7VMmfKQ,11408
12
12
  ipyvasp/surface.py,sha256=MjE5oB0wW6Pca_C-xu8rN6OMH7lUEeNPNyM7Kz_Im-8,23766
13
13
  ipyvasp/utils.py,sha256=hiAV76jEMuDt1Wp22imrnsSgetjxmUKlskRA7CcK6BU,15261
@@ -17,9 +17,9 @@ ipyvasp/core/parser.py,sha256=C3CaZsJbPME_ttYlYy4DXeOdL7dnkXs-cHRwFZL6bio,38058
17
17
  ipyvasp/core/plot_toolkit.py,sha256=cktbPZTJ4K0_6-vKYqtQ1xIIPZg-gHJY5793M9XoYQ0,35754
18
18
  ipyvasp/core/serializer.py,sha256=XFUqMEGH4X2nicKRym7CljsPDnA3qcnFHrXl0wEHsfw,33159
19
19
  ipyvasp/core/spatial_toolkit.py,sha256=8DBYTiBFWJ7OBKuvOPw7UoEVCyNjJhSW0OcudjYZvAw,14748
20
- ipyvasp-0.7.9.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
- ipyvasp-0.7.9.dist-info/METADATA,sha256=iHsfuXfkYUzgtLjA6WOo543jBDDpEiukCFXLim1UlvA,2353
22
- ipyvasp-0.7.9.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
- ipyvasp-0.7.9.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
- ipyvasp-0.7.9.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
- ipyvasp-0.7.9.dist-info/RECORD,,
20
+ ipyvasp-0.8.0.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-0.8.0.dist-info/METADATA,sha256=wfynl1_bEhTeqZIT3_pEZtCFgiTrmJc3A-SEmLYFA7U,2353
22
+ ipyvasp-0.8.0.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
+ ipyvasp-0.8.0.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
+ ipyvasp-0.8.0.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-0.8.0.dist-info/RECORD,,