setlr 0.2.18__tar.gz → 0.2.19__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: setlr
3
- Version: 0.2.18
3
+ Version: 0.2.19
4
4
  Summary: setlr is a tool for Semantic Extraction, Transformation, and Loading.
5
5
  Home-page: http://packages.python.org/setlr
6
6
  Author: Jamie McCusker
@@ -416,9 +416,11 @@ def clone(value):
416
416
 
417
417
  functions = {}
418
418
  def get_function(expr, local_keys):
419
- key = tuple([expr]+sorted(local_keys))
419
+ used_local_keys = [k for k in local_keys if k in expr]
420
+ key = tuple([expr]+sorted(used_local_keys))
420
421
  if key not in functions:
421
- script = '''lambda %s: %s'''% (', '.join(sorted(local_keys)), expr)
422
+ script = '''lambda %s,**kwargs: %s'''% (', '.join(sorted(used_local_keys)), expr)
423
+ #print(script)
422
424
  fn = eval(script)
423
425
  fn.__name__ = expr.encode("ascii", "ignore").decode('utf8')
424
426
  functions[key] = fn
@@ -431,6 +433,23 @@ def get_template(templ):
431
433
  templates[templ] = t
432
434
  return templates[templ]
433
435
 
436
+ def flatten_lists(o):
437
+ if isinstance(o, list):
438
+ result = []
439
+ for x in o:
440
+ flattened = flatten_lists(x)
441
+ if isinstance(flattened, list):
442
+ result.extend(flattened)
443
+ else:
444
+ result.append(flattened)
445
+ return result
446
+ elif isinstance(o, dict):
447
+ for key in o.keys():
448
+ o[key] = flatten_lists(o[key])
449
+ return o
450
+ else:
451
+ return o
452
+
434
453
  def process_row(row, template, rowname, table, resources, transform, variables):
435
454
  result = []
436
455
  e = {'row':row,
@@ -534,7 +553,9 @@ def process_row(row, template, rowname, table, resources, transform, variables):
534
553
  fn = get_function(expression, list(env.keys()))
535
554
  v = fn(**env)
536
555
  if v is not None:
537
- if len(variable_list) == 1:
556
+ if len(variable_list) == 1 and not (
557
+ isinstance(v, collections.Iterable)
558
+ and not isinstance(v, str)):
538
559
  v = [v]
539
560
  new_env = dict(env)
540
561
  for i, variable in enumerate(variable_list):
@@ -581,7 +602,8 @@ def process_row(row, template, rowname, table, resources, transform, variables):
581
602
  parent[key] = this
582
603
  else:
583
604
  parent.append(this)
584
- return result
605
+
606
+ return flatten_lists(result)
585
607
 
586
608
  def json_transform(transform, resources):
587
609
  logger.info("Transforming %s", transform.identifier)
@@ -646,6 +668,7 @@ def json_transform(transform, resources):
646
668
  }
647
669
  if context is not None:
648
670
  root['@context'] = context
671
+ #logger.debug(json.dumps(root, indent=4))
649
672
  #before = len(result)
650
673
  #graph = ConjunctiveGraph(identifier=generated.identifier)
651
674
  #graph.parse(data=json.dumps(root),format="json-ld")
@@ -762,7 +785,7 @@ def load(load_resource, resources):
762
785
  #print fmt
763
786
  with _load_open(generated) as o:
764
787
  file_graph.serialize(o, format=fmt)
765
-
788
+
766
789
  elif generated[RDF.type:sd.Service]:
767
790
  from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
768
791
  endpoint = generated.value(sd.endpoint, default=generated).identifier
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: setlr
3
- Version: 0.2.18
3
+ Version: 0.2.19
4
4
  Summary: setlr is a tool for Semantic Extraction, Transformation, and Loading.
5
5
  Home-page: http://packages.python.org/setlr
6
6
  Author: Jamie McCusker
@@ -10,7 +10,7 @@ def read(fname):
10
10
 
11
11
  setup(
12
12
  name = "setlr",
13
- version = "0.2.18",
13
+ version = "0.2.19",
14
14
  author = "Jamie McCusker",
15
15
  author_email = "mccusj@cs.rpi.edu",
16
16
  description = ("setlr is a tool for Semantic Extraction, Transformation, and Loading."),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes