-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_script.py
executable file
·78 lines (58 loc) · 1.99 KB
/
template_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# __Filename__ - __Class__ script by __User__ __Year__
"""
<!!! Script description !!!>
"""
# Modules
import unittest
import sys
import os
import argparse
import re
import random
import subprocess
import getpass
import shutil
###############################################################################
# __Class__ Class (Main Program)
###############################################################################
class __Class__:
""" __Class__ representation """
def __init__(self, arg_str=""):
""" Default constructor """
# Argument parsing
self.arg_str = arg_str
parser = argparse.ArgumentParser(
description="__Class__ script")
parser.add_argument(
"arg", nargs="?", default="", help="optional argument")
parser.add_argument(
"-a", action="store_true", default="", help="Option")
self.args = parser.parse_args(self.arg_str.split())
def run(self, test=False):
""" Main execution function """
if test:
return
###############################################################################
# Unit Tests
###############################################################################
class unitTests(unittest.TestCase):
tmp_area = "/tmp/ut" + getpass.getuser()
test_area = tmp_area + "/t" + str(random.randrange(10000))
tmp_file = test_area + "/f" + str(random.randrange(10000))
def setUp(self):
os.makedirs(self.test_area, exist_ok=True)
def test___Class___class__basic_functionality(self):
""" __Class__ class basic testing """
d = __Class__()
self.assertEqual(d.args.a, "")
def test___Class___class__run(self):
""" Main execution function """
d = __Class__()
d.run(test=True)
def test_xcleanup(self):
shutil.rmtree(self.tmp_area)
if __name__ == "__main__":
if sys.argv[-1] == "-ut":
unittest.main(argv=[" "])
__Class__(" ".join(sys.argv[1:])).run()