Skip to content

Commit 89120df

Browse files
committed
publishing -> done ?
1 parent f6b1712 commit 89120df

File tree

1 file changed

+63
-37
lines changed

1 file changed

+63
-37
lines changed

legal_tools/management/commands/publish.py

+63-37
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def save_index_rdf(output_dir, filename):
125125
# Function is at top level of module so that it can be pickled by
126126
# multiprocessing.
127127
index_url = f"/rdf/{filename}"
128-
relpath = f"rdf/{filename}"
128+
relpath = f"{filename}"
129129
save_url_as_static_file(output_dir, url=index_url, relpath=relpath)
130130

131131

@@ -261,7 +261,58 @@ def copy_tools_rdfs(self):
261261
copyfile(os.path.join(tools_rdf_dir, rdf), dest_file)
262262
LOG.debug(f" {relative_name}")
263263

264-
def copy_meta_rdfs(self):
264+
# def copy_meta_rdfs(self): TO BE REMOVED
265+
# hostname = socket.gethostname()
266+
# legacy_dir = self.legacy_dir
267+
# output_dir = self.output_dir
268+
# meta_rdf_dir = os.path.join(legacy_dir, "rdf-meta")
269+
# meta_files = [
270+
# meta_file
271+
# for meta_file in os.listdir(meta_rdf_dir)
272+
# if os.path.isfile(os.path.join(meta_rdf_dir, meta_file))
273+
# ]
274+
# meta_files.sort()
275+
# dest_dir = os.path.join(output_dir, "rdf")
276+
# os.makedirs(dest_dir, exist_ok=True)
277+
# LOG.debug(f"{hostname}:{output_dir}")
278+
# LOG.info("Copying RDF information and metadata")
279+
# for meta_file in meta_files:
280+
# dest_relative = os.path.join("rdf", meta_file)
281+
# dest_full = os.path.join(output_dir, dest_relative)
282+
# LOG.debug(f" {dest_relative}")
283+
# copyfile(os.path.join(meta_rdf_dir, meta_file), dest_full)
284+
# if meta_file == "index.rdf":
285+
# os.makedirs(
286+
# os.path.join(output_dir, "licenses"), exist_ok=True
287+
# )
288+
# dir_fd = os.open(output_dir, os.O_RDONLY)
289+
# symlink = os.path.join("licenses", meta_file)
290+
# try:
291+
# os.symlink(f"../{dest_relative}", symlink, dir_fd=dir_fd)
292+
# LOG.debug(f" ^{symlink}")
293+
# finally:
294+
# os.close(dir_fd)
295+
# elif meta_file == "ns.html":
296+
# dir_fd = os.open(output_dir, os.O_RDONLY)
297+
# symlink = meta_file
298+
# try:
299+
# os.symlink(dest_relative, symlink, dir_fd=dir_fd)
300+
# LOG.debug(f" ^{symlink}")
301+
# finally:
302+
# os.close(dir_fd)
303+
# elif meta_file == "schema.rdf":
304+
# dir_fd = os.open(output_dir, os.O_RDONLY)
305+
# symlink = meta_file
306+
# try:
307+
# os.symlink(dest_relative, symlink, dir_fd=dir_fd)
308+
# LOG.debug(f" ^{symlink}")
309+
# finally:
310+
# os.close(dir_fd)
311+
312+
def write_rdf_meta(self):
313+
"""
314+
Generate the index.rdf, images.rdf and copies the rest.
315+
"""
265316
hostname = socket.gethostname()
266317
legacy_dir = self.legacy_dir
267318
output_dir = self.output_dir
@@ -275,12 +326,19 @@ def copy_meta_rdfs(self):
275326
dest_dir = os.path.join(output_dir, "rdf")
276327
os.makedirs(dest_dir, exist_ok=True)
277328
LOG.debug(f"{hostname}:{output_dir}")
278-
LOG.info("Copying RDF information and metadata")
329+
279330
for meta_file in meta_files:
280331
dest_relative = os.path.join("rdf", meta_file)
281332
dest_full = os.path.join(output_dir, dest_relative)
282-
LOG.debug(f" {dest_relative}")
283-
copyfile(os.path.join(meta_rdf_dir, meta_file), dest_full)
333+
filenames = ["index.rdf", "images.rdf"]
334+
if meta_file in filenames:
335+
LOG.info(f"Writing {meta_file}")
336+
save_index_rdf(dest_dir, meta_file)
337+
else:
338+
LOG.info(f"Copying {meta_file}")
339+
LOG.debug(f" {dest_relative}")
340+
copyfile(os.path.join(meta_rdf_dir, meta_file), dest_full)
341+
284342
if meta_file == "index.rdf":
285343
os.makedirs(
286344
os.path.join(output_dir, "licenses"), exist_ok=True
@@ -309,38 +367,6 @@ def copy_meta_rdfs(self):
309367
finally:
310368
os.close(dir_fd)
311369

312-
def write_rdf_meta(self):
313-
"""
314-
Generate the index.rdf, images.rdf and copies the rest.
315-
"""
316-
hostname = socket.gethostname()
317-
legacy_dir = self.legacy_dir
318-
output_dir = self.output_dir
319-
meta_rdf_dir = os.path.join(legacy_dir, "rdf-meta")
320-
meta_files = [
321-
meta_file
322-
for meta_file in os.listdir(meta_rdf_dir)
323-
if os.path.isfile(os.path.join(meta_rdf_dir, meta_file))
324-
]
325-
meta_files.sort()
326-
dest_dir = os.path.join(output_dir, "rdf")
327-
os.makedirs(dest_dir, exist_ok=True)
328-
LOG.debug(f"{hostname}:{output_dir}")
329-
330-
for meta_file in meta_files:
331-
dest_relative = os.path.join("rdf", meta_file)
332-
dest_full = os.path.join(output_dir, dest_relative)
333-
filenames = ["index.rdf", "images.rdf"]
334-
if meta_file in filenames:
335-
for filename in filenames:
336-
rdf_path = os.path.join(dest_dir, filename)
337-
LOG.info(f"Writing {filename}")
338-
save_index_rdf(rdf_path, filename)
339-
else:
340-
LOG.info(f"Copying {meta_file}")
341-
LOG.debug(f" {dest_relative}")
342-
copyfile(os.path.join(meta_rdf_dir, meta_file), dest_full)
343-
344370
def copy_legal_code_plaintext(self):
345371
hostname = socket.gethostname()
346372
legacy_dir = self.legacy_dir

0 commit comments

Comments
 (0)