rda-python-common 2.1.2__py3-none-any.whl → 2.1.4__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.
@@ -184,6 +184,23 @@ class PgLOG:
184
184
  self.PBSSTATS = {}
185
185
  # set additional common PGLOG values
186
186
  self.set_common_pglog()
187
+ self.OUTPUT = None
188
+
189
+ def open_output(self, outfile=None):
190
+ """Open the result output destination.
191
+
192
+ Args:
193
+ outfile (str, optional): Path to a file to write results to. If
194
+ ``None`` or omitted, output is directed to ``sys.stdout``.
195
+ """
196
+ if outfile: # result output file
197
+ try:
198
+ self.OUTPUT = open(outfile, 'w')
199
+ except Exception as e:
200
+ self.pglog("{}: Error open file to write - {}".format(outfile, str(e)), self.PGOPT['extlog'])
201
+ else: # result to STDOUT
202
+ if self.OUTPUT and self.OUTPUT != sys.stdout: self.OUTPUT.close()
203
+ self.OUTPUT = sys.stdout
187
204
 
188
205
  def current_datetime(self, ctime=0):
189
206
  """Return a datetime string in YYYYMMDDHHMMSS format.
@@ -573,6 +590,7 @@ class PgLOG:
573
590
  stat: Exit status code passed to ``sys.exit`` (default 0).
574
591
  """
575
592
  if self.PGLOG['PGDBBUF']: self.PGLOG['PGDBBUF'].close()
593
+ if self.OUTPUT and self.OUTPUT != sys.stdout: self.OUTPUT.close()
576
594
  sys.exit(stat)
577
595
 
578
596
  def get_error_command(self, ctime, logact):
@@ -47,7 +47,6 @@ class PgOPT(PgFile):
47
47
  def __init__(self):
48
48
  """Initialize PgOPT and its parent PgFile, setting up all class attributes."""
49
49
  super().__init__() # initialize parent class
50
- self.OUTPUT = None
51
50
  self.CMDOPTS = {}
52
51
  self.INOPTS = {}
53
52
  # global variables are used by all applications and this package.
@@ -290,21 +289,6 @@ class PgOPT(PgFile):
290
289
  return odval[0] # return the first char of a default string
291
290
  return None
292
291
 
293
- def open_output(self, outfile=None):
294
- """Open the result output destination.
295
-
296
- Args:
297
- outfile (str, optional): Path to a file to write results to. If
298
- ``None`` or omitted, output is directed to ``sys.stdout``.
299
- """
300
- if outfile: # result output file
301
- try:
302
- self.OUTPUT = open(outfile, 'w')
303
- except Exception as e:
304
- self.pglog("{}: Error open file to write - {}".format(outfile, str(e)), self.PGOPT['extlog'])
305
- else: # result to STDOUT
306
- self.OUTPUT = sys.stdout
307
-
308
292
  def validate_infile_names(self, dsid):
309
293
  """Validate all input file names against the expected dataset ID.
310
294
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 2.1.2
3
+ Version: 2.1.4
4
4
  Summary: RDA Python common library codes shared by other RDA python packages
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-common
@@ -12,16 +12,16 @@ rda_python_common/pg_cmd.py,sha256=hQZaW80eFqEUoF0vZHtGuvBEWXbXdY0Nvj6rFIQGboo,3
12
12
  rda_python_common/pg_dbi.py,sha256=R-ZzHUItAxma_rCTrelDakFQDl8yEtOTKo4IRfzKl_Q,116269
13
13
  rda_python_common/pg_file.py,sha256=Gz0R1wISIMHr7UBPGqeK6eJlLCjwQcP_V6n65WxjTEM,161927
14
14
  rda_python_common/pg_lock.py,sha256=Il-pY81JtEDMWtwqW6lEM-EtKbhNI6rug8VMCdkGgNc,32703
15
- rda_python_common/pg_log.py,sha256=Pro31Zt-ijZAss7Ikug3Fa-PxrnsHnNHMbkPEnuU1Lw,79905
16
- rda_python_common/pg_opt.py,sha256=_vwhaEqJ8eZFyRrEjgj0o6L687NTye-0TKMjQk-8_Ww,83117
15
+ rda_python_common/pg_log.py,sha256=Zte9joy46hn2RsJPNpisHLjxZI-mDdcXY4aSiMNlIoY,80661
16
+ rda_python_common/pg_opt.py,sha256=N45DIY2O3S7ogABOHUecfiKwQY1_O4X7WYYZGLdnhOI,82506
17
17
  rda_python_common/pg_password.py,sha256=X-eIDwdqBhtrhrbDTNWle-0JtWsyIVZdDOZaBu7cFHM,2343
18
18
  rda_python_common/pg_sig.py,sha256=Dz7QKOkwYchbhVZgQxQqFrUmGaxer2bm8D2K99ig5L0,52760
19
19
  rda_python_common/pg_split.py,sha256=yOeUSRzgQlwNGzv76ZLCZtsjzDQw0NeYXz0IV0RZgXQ,16343
20
20
  rda_python_common/pg_util.py,sha256=1f25D4xyPMerW55q42CQOD0WYAoFYL2A8Opl4rHA8N4,87393
21
21
  rda_python_common/pgpassword.py,sha256=WXEq88XgkQSmJ2j2MX0HSVEUFZOFu-gokRJYvEQj_u4,2900
22
- rda_python_common-2.1.2.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
23
- rda_python_common-2.1.2.dist-info/METADATA,sha256=Ybtbq9WTGsmYyK2sIr3pt56IEVopnaPnsBLBbaHLqDs,740
24
- rda_python_common-2.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
25
- rda_python_common-2.1.2.dist-info/entry_points.txt,sha256=pZgVNWspcK-F1TbPav7C3C9NdeHDZMm_25fW9weix00,65
26
- rda_python_common-2.1.2.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
27
- rda_python_common-2.1.2.dist-info/RECORD,,
22
+ rda_python_common-2.1.4.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
23
+ rda_python_common-2.1.4.dist-info/METADATA,sha256=pSoi81ZdpdKdBmK80sB_n_UiQ1xQJg2dglKx6_aq-jM,740
24
+ rda_python_common-2.1.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
25
+ rda_python_common-2.1.4.dist-info/entry_points.txt,sha256=pZgVNWspcK-F1TbPav7C3C9NdeHDZMm_25fW9weix00,65
26
+ rda_python_common-2.1.4.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
27
+ rda_python_common-2.1.4.dist-info/RECORD,,