python-startfile 0.0.1__tar.gz → 0.0.2__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.1
2
2
  Name: python-startfile
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Python startfile.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-startfile
6
6
  License: MIT
@@ -51,7 +51,7 @@ pip install -U python-startfile
51
51
  ### Commad
52
52
 
53
53
  ```console
54
- $ python -m startfile -h
54
+ $ startfile -h
55
55
  usage: startfile.py [-h] [-v] [path ...]
56
56
 
57
57
  Start file(s) with its/their associated application.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-startfile"
3
- version = "0.0.1"
3
+ version = "0.0.2"
4
4
  description = "Python startfile."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -22,9 +22,13 @@ include = [
22
22
  "LICENSE",
23
23
  ]
24
24
 
25
+ [tool.poetry.scripts]
26
+ python-startfile = "startfile.__main__:main"
27
+ startfile = "startfile.__main__:main"
28
+
25
29
  [build-system]
26
30
  requires = ["poetry-core"]
27
31
  build-backend = "poetry.core.masonry.api"
28
32
 
29
33
  [[tool.poetry.packages]]
30
- include = "startfile.py"
34
+ include = "startfile"
@@ -19,7 +19,7 @@ pip install -U python-startfile
19
19
  ### Commad
20
20
 
21
21
  ```console
22
- $ python -m startfile -h
22
+ $ startfile -h
23
23
  usage: startfile.py [-h] [-v] [path ...]
24
24
 
25
25
  Start file(s) with its/their associated application.
@@ -2,29 +2,11 @@
2
2
  # coding: utf-8
3
3
 
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
- __version__ = (0, 0, 1)
5
+ __version__ = (0, 0, 2)
6
6
  __all__ = ["startfile", "startfile_async"]
7
7
 
8
- if __name__ == "__main__":
9
- from argparse import ArgumentParser, RawTextHelpFormatter
10
-
11
- parser = ArgumentParser(
12
- description="Start file(s) with its/their associated application.",
13
- formatter_class=RawTextHelpFormatter,
14
- )
15
- parser.add_argument("paths", nargs="*", metavar="path", help="paths to files or directories")
16
- parser.add_argument("-v", "--version", action="store_true", help="print the current version")
17
-
18
- args = parser.parse_args()
19
- if args.version:
20
- print(".".join(map(str, __version__)))
21
- raise SystemExit(0)
22
- paths = args.paths
23
- if not paths:
24
- parser.parse_args(["-h"])
25
-
26
8
  try:
27
- from os import startfile
9
+ from os import startfile # type: ignore
28
10
  except ImportError:
29
11
  from asyncio import create_subprocess_exec, create_subprocess_shell
30
12
  from platform import system
@@ -60,11 +42,6 @@ else:
60
42
  from functools import wraps
61
43
 
62
44
  @wraps(startfile)
63
- async def startfile_aysnc(*args, **kwds):
45
+ async def startfile_async(*args, **kwds):
64
46
  return await to_thread(startfile, *args, **kwds)
65
47
 
66
-
67
- if __name__ == "__main__":
68
- for path in paths:
69
- startfile(path)
70
-
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python3
2
+ # coding: utf-8
3
+
4
+ __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
+
6
+ from argparse import ArgumentParser, RawTextHelpFormatter
7
+
8
+ from . import startfile, __version__
9
+
10
+ def main():
11
+ parser = ArgumentParser(
12
+ description="Start file(s) with its/their associated application.",
13
+ formatter_class=RawTextHelpFormatter,
14
+ )
15
+ parser.add_argument("paths", metavar="path", nargs="*", help="path to file or directory")
16
+ parser.add_argument("-v", "--version", action="store_true", help="print the current version")
17
+
18
+ args = parser.parse_args()
19
+ if args.version:
20
+ print(".".join(map(str, __version__)))
21
+ raise SystemExit(0)
22
+ paths = args.paths
23
+ if not paths:
24
+ parser.parse_args(["-h"])
25
+
26
+ for path in paths:
27
+ startfile(path)
28
+
29
+ if __name__ == "__main__":
30
+ main()