setlr 0.2.11__tar.gz → 0.2.12__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,10 +1,10 @@
1
1
  #!/Users/jimmccusker/opt/ipython/bin/python
2
- # EASY-INSTALL-ENTRY-SCRIPT: 'setlr==0.2.11','console_scripts','setlr'
3
- __requires__ = 'setlr==0.2.11'
2
+ # EASY-INSTALL-ENTRY-SCRIPT: 'setlr==0.2.12','console_scripts','setlr'
3
+ __requires__ = 'setlr==0.2.12'
4
4
  import sys
5
5
  from pkg_resources import load_entry_point
6
6
 
7
7
  if __name__ == '__main__':
8
8
  sys.exit(
9
- load_entry_point('setlr==0.2.11', 'console_scripts', 'setlr')()
9
+ load_entry_point('setlr==0.2.12', 'console_scripts', 'setlr')()
10
10
  )
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
+ from builtins import str
5
+ from builtins import next
6
+ from builtins import object
4
7
  from rdflib import *
5
8
  from rdflib.util import guess_format
6
9
  import rdflib
@@ -11,7 +14,7 @@ import requests
11
14
  import pandas
12
15
  import re
13
16
  import os
14
- from six import text_type as unicode
17
+ from six import text_type as str
15
18
 
16
19
  from jinja2 import Template
17
20
  from toposort import toposort_flatten
@@ -19,7 +22,7 @@ from numpy import isnan
19
22
  import uuid
20
23
  import tempfile
21
24
  import ijson
22
- from . import iterparse_filter
25
+ import iterparse_filter
23
26
  #import xml.etree.ElementTree as ET
24
27
  import xml.etree.ElementTree
25
28
 
@@ -174,7 +177,7 @@ class FileLikeFromIter(object):
174
177
 
175
178
  def read(self, n=None):
176
179
  if n is None:
177
- return self.data + ''.join(l for l in self.iter)
180
+ return self.data + b''.join(l for l in self.iter)
178
181
  else:
179
182
  while len(self.data) < n:
180
183
  try:
@@ -461,7 +464,7 @@ def process_row(row, template, rowname, table, resources, transform, variables):
461
464
  if isinstance(value, dict):
462
465
  if '@if' in value:
463
466
  try:
464
- fn = get_function(value['@if'], env.keys())
467
+ fn = get_function(value['@if'], list(env.keys()))
465
468
  incl = fn(**env)
466
469
  if incl is None or not incl:
467
470
  continue
@@ -474,12 +477,12 @@ def process_row(row, template, rowname, table, resources, transform, variables):
474
477
  except Exception as e:
475
478
  trace = sys.exc_info()[2]
476
479
  logger.error("Error in conditional %s\nRelevant Environment:", value['@if'])
477
- for key, v in env.items():
480
+ for key, v in list(env.items()):
478
481
  #if key in value['@if']:
479
482
  if hasattr(v, 'findall'):
480
483
  v = xml.etree.ElementTree.tostring(v)
481
484
  logger.error(key + "\t" + str(v)[:1000])
482
- raise(e, None, trace)
485
+ raise e
483
486
  if '@for' in value:
484
487
  f = value['@for']
485
488
  if isinstance(f, list):
@@ -492,7 +495,7 @@ def process_row(row, template, rowname, table, resources, transform, variables):
492
495
  else:
493
496
  del val['@for']
494
497
  try:
495
- fn = get_function(expression, env.keys())
498
+ fn = get_function(expression, list(env.keys()))
496
499
  values = fn(**env)
497
500
  if values is not None:
498
501
  for v in values:
@@ -508,8 +511,8 @@ def process_row(row, template, rowname, table, resources, transform, variables):
508
511
  except Exception as e:
509
512
  trace = sys.exc_info()[2]
510
513
  logger.error("Error in @for: %s", value['@for'])
511
- logger.error("Locals: %s", env.keys())
512
- raise(e, None, trace)
514
+ logger.error("Locals: %s", list(env.keys()))
515
+ raise e
513
516
  continue
514
517
  if '@with' in value:
515
518
  f = value['@with']
@@ -523,7 +526,7 @@ def process_row(row, template, rowname, table, resources, transform, variables):
523
526
  else:
524
527
  del val['@with']
525
528
  try:
526
- fn = get_function(expression, env.keys())
529
+ fn = get_function(expression, list(env.keys()))
527
530
  v = fn(**env)
528
531
  if v is not None:
529
532
  if len(variable_list) == 1:
@@ -538,11 +541,11 @@ def process_row(row, template, rowname, table, resources, transform, variables):
538
541
  except Exception as e:
539
542
  trace = sys.exc_info()[2]
540
543
  logger.error("Error in with: %s", value['@with'])
541
- logger.error("Locals: %s", env.keys())
542
- raise(e, None, trace)
544
+ logger.error("Locals: %s", list(env.keys()))
545
+ raise e
543
546
  continue
544
547
  this = {}
545
- for child in value.items():
548
+ for child in list(value.items()):
546
549
  if child[0] == '@if':
547
550
  continue
548
551
  if child[0] == '@for':
@@ -552,20 +555,20 @@ def process_row(row, template, rowname, table, resources, transform, variables):
552
555
  this = []
553
556
  for child in value:
554
557
  todo.append((child, this, env))
555
- elif isinstance(value, unicode):
558
+ elif isinstance(value, str):
556
559
  try:
557
- template = get_template(unicode(value))
560
+ template = get_template(str(value))
558
561
  this = template.render(**env)
559
562
  except Exception as e:
560
563
  trace = sys.exc_info()[2]
561
564
  logger.error("Error in template %s %s", value, type(value))
562
565
  logger.error("Relevant Environment:")
563
- for key, v in env.items():
566
+ for key, v in list(env.items()):
564
567
  #if key in value:
565
568
  if hasattr(v, 'findall'):
566
569
  v = xml.etree.ElementTree.tostring(v)
567
570
  logger.error(key + "\t" + str(v)[:1000])
568
- raise(e, None, trace)
571
+ raise e
569
572
  else:
570
573
  this = value
571
574
 
@@ -610,7 +613,7 @@ def json_transform(transform, resources):
610
613
  line = int(re.search("line ([0-9]+)", e.message).group(1))
611
614
  logger.error("Error in parsing JSON Template at line %d:", line)
612
615
  logger.error('\n'.join(["%d: %s"%(i+line-3, x) for i, x in enumerate(s.split("\n")[line-3:line+4])]))
613
- raise(e, None, trace)
616
+ raise e
614
617
  context = transform.value(setl.hasContext)
615
618
  if context is not None:
616
619
  context = json.loads(context.value)
@@ -651,7 +654,7 @@ def json_transform(transform, resources):
651
654
  logger.error("Error on %s %s", rowname, row)
652
655
  else:
653
656
  logger.error("Error on %s", rowname)
654
- raise(e, None, trace)
657
+ raise e
655
658
 
656
659
  resources[generated.identifier] = result
657
660
 
@@ -3,8 +3,13 @@
3
3
  For details see:
4
4
  http://dalkescientific.com/writings/diary/archive/2006/11/06/iterparse_filter.html
5
5
  """
6
+ from __future__ import print_function
6
7
  # I have got to rearrange my site to use shorter URLs.
7
8
 
9
+ from future import standard_library
10
+ standard_library.install_aliases()
11
+ from builtins import zip
12
+ from builtins import object
8
13
  __version__ = "0.9-experimental"
9
14
 
10
15
  import re
@@ -543,7 +548,7 @@ def test_syntax():
543
548
  (xpath, tag_list, got, bool(expect)))
544
549
 
545
550
  def test_filtering():
546
- import cStringIO as StringIO
551
+ import io as StringIO
547
552
  f = StringIO.StringIO("""\
548
553
  <A><AA>
549
554
  <B xmlns="http://z/"><C/><spam:D xmlns:spam="http://spam/">eggs</spam:D></B>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: setlr
3
- Version: 0.2.11
3
+ Version: 0.2.12
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: Jim McCusker
@@ -0,0 +1 @@
1
+ {"is_release": false, "git_version": "0b4b76f"}
@@ -3,7 +3,7 @@ cython
3
3
  numpy
4
4
  rdflib
5
5
  rdflib-jsonld
6
- pandas
6
+ pandas==0.22.0
7
7
  requests
8
8
  toposort
9
9
  beautifulsoup4
@@ -1 +0,0 @@
1
- {"is_release": false, "git_version": "bd1ed0e"}