Skip to content

Commit d84d5eb

Browse files
committed
Change os.path to Path use
1 parent 8b502c9 commit d84d5eb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

diviner/file_utils.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@
3030
except KeyError:
3131
user = "none"
3232

33-
home = os.environ["HOME"]
33+
home = Path.home()
3434

3535
if sys.platform == "darwin":
36-
datapath = pjoin(home, "data", "diviner")
37-
outpath = pjoin(datapath, "out")
38-
kernelpath = pjoin(home, "data", "spice", "diviner")
39-
codepath = pjoin(home, "Dropbox", "src", "diviner")
40-
l1adatapath = pjoin(datapath, "l1a_data")
41-
rdrdatapath = pjoin(datapath, "opsRDR")
42-
rdrrdatapath = pjoin(os.environ["HOME"], "data", "diviner", "rdrr_data")
43-
rdrsdatapath = pjoin(os.environ["HOME"], "data", "diviner", "rdrs_data")
36+
datapath = home / "Dropbox/data/diviner"
37+
outpath = datapath / "out"
38+
kernelpath = home / "data/spice/diviner"
39+
codepath = home / "Dropbox/src/diviner"
40+
l1adatapath = datapath / "l1a_data"
41+
rdrdatapath = datapath / "opsRDR"
42+
rdrrdatapath = datapath / "rdrr_data"
43+
rdrsdatapath = datapath / "rdrs_data"
4444
else:
45-
datapath = pjoin(path.sep, hostname, user)
46-
outpath = pjoin(datapath, "rdr_out")
47-
kernelpath = pjoin(datapath, "kernels")
48-
codepath = pjoin(os.environ["HOME"], "src/diviner")
45+
datapath = Path(hostname) / user
46+
outpath = datapath / "rdr_out"
47+
kernelpath = datapath / "kernels"
48+
codepath = home / "src/diviner"
4949
feipath = Path("/q/marks/feidata/")
5050
l1adatapath = feipath / "DIV:opsL1A/data"
5151
rdrdatapath = feipath / "DIV:opsRdr/data"
@@ -59,7 +59,7 @@
5959
def scp_l1a_file(tstr):
6060
src_host = "luna4"
6161
target_path = pjoin(datapath, "l1a_data")
62-
src_datadir = "/luna1/marks/feidata/DIV:opsL1A/data"
62+
src_datadir = l1adatapath
6363
cmd = f"scp {src_host}:{src_datadir}/{tstr}_L1A.TAB {target_path}"
6464
print(cmd)
6565
call(cmd, shell=True)
@@ -281,7 +281,7 @@ class FileName(object):
281281
"""Managing class for file name attributes."""
282282

283283
ext = "" # fill in child class !
284-
datapath = "" # fill in child class !
284+
datapath = Path.home() # fill in child class !
285285

286286
@classmethod
287287
def from_tstr(cls, tstr):
@@ -937,10 +937,10 @@ def year_folder(self):
937937

938938
def find_fnames(self):
939939
"Needs self.datapath to be defined in derived class."
940-
fnames = list(self.year_folder.glob(self.tstr+'*'))
940+
fnames = list(self.year_folder.glob(self.tstr + "*"))
941941
if not fnames:
942942
print("No files found. Searched like this:\n")
943-
print(self.year_folder / (self.tstr + '*'))
943+
print(self.year_folder / (self.tstr + "*"))
944944
return sorted(fnames)
945945

946946

0 commit comments

Comments
 (0)