Skip to content

Commit f4fcc36

Browse files
authored
Merge pull request #442 from manu-chroma/unicode_literal_usage
Working towards python3 compatible codebase
2 parents af08264 + a6bb3f9 commit f4fcc36

File tree

121 files changed

+929
-3855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+929
-3855
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ eggs/
1515
*~
1616
\#*\#
1717
.desktop
18+
19+
# virtualenv
20+
venv/
21+
venv3/
22+
23+
# pycharm
24+
.idea/
25+
26+
# typshed repo
27+
typeshed/2and3/schema_salad
28+
typeshed/2and3/ruamel/yaml
29+
30+
31+
#mypy
32+
.mypy_cache/

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,26 @@ list-author-emails:
152152
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
153153

154154

155-
mypy: ${PYSOURCES}
156-
rm -Rf typeshed/2.7/ruamel/yaml
155+
mypy2: ${PYSOURCES}
156+
rm -Rf typeshed/2and3/ruamel/yaml
157157
ln -s $(shell python -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
158-
typeshed/2.7/ruamel/yaml
159-
rm -Rf typeshed/2.7/schema_salad
158+
typeshed/2and3/ruamel/yaml
159+
rm -Rf typeshed/2and3/schema_salad
160160
ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
161-
typeshed/2.7/schema_salad
162-
MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls \
163-
--warn-redundant-casts --warn-unused-ignores --fast-parser \
161+
typeshed/2and3/schema_salad
162+
MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
163+
--warn-redundant-casts --warn-unused-ignores \
164164
cwltool
165165

166166
mypy3: ${PYSOURCES}
167-
rm -Rf typeshed/3/ruamel/yaml
167+
rm -Rf typeshed/2and3/ruamel/yaml
168168
ln -s $(shell python3 -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
169-
typeshed/3/ruamel/yaml
170-
rm -Rf typeshed/3/schema_salad
169+
typeshed/2and3/ruamel/yaml
170+
rm -Rf typeshed/2and3/schema_salad
171171
ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
172-
typeshed/3/schema_salad
173-
MYPYPATH=typeshed/3 mypy --disallow-untyped-calls \
174-
--warn-redundant-casts --warn-unused-ignores --fast-parser \
172+
typeshed/2and3/schema_salad
173+
MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
174+
--warn-redundant-casts --warn-unused-ignores \
175175
cwltool
176176

177177
FORCE:

cwlref-runner/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
2+
from __future__ import absolute_import
33
import os
44

55
from setuptools import setup, find_packages

cwltool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import absolute_import
23
"""Convienance entry point for cwltool.
34
45
This can be used instead of the recommended method of `./setup.py install`

cwltool/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
from __future__ import absolute_import
12
__author__ = '[email protected]'

cwltool/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
import sys
23

34
from . import main

cwltool/builder.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import absolute_import
12
import copy
2-
from typing import Any, Callable, Text, Type, Union
3+
from typing import Any, Callable, Dict, List, Text, Type, Union
34

5+
import six
46
from six import iteritems, string_types
57

68
import avro
@@ -15,6 +17,11 @@
1517
from .stdfsaccess import StdFsAccess
1618
from .utils import aslist
1719

20+
# if six.PY3:
21+
# AvroSchemaFromJSONData = avro.schema.SchemaFromJSONData
22+
# else:
23+
AvroSchemaFromJSONData = avro.schema.make_avsc_object
24+
1825
CONTENT_LIMIT = 64 * 1024
1926

2027

@@ -86,7 +93,7 @@ def bind_input(self, schema, datum, lead_pos=None, tail_pos=None):
8693
elif isinstance(t, dict) and "name" in t and self.names.has_name(t["name"], ""):
8794
avsc = self.names.get_name(t["name"], "")
8895
else:
89-
avsc = avro.schema.make_avsc_object(t, self.names)
96+
avsc = AvroSchemaFromJSONData(t, self.names)
9097
if validate.validate(avsc, datum):
9198
schema = copy.deepcopy(schema)
9299
schema["type"] = t

cwltool/cwlrdf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
from typing import IO, Any, Dict, Text
23

34
from rdflib import Graph

cwltool/docker.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from __future__ import absolute_import
12
import logging
23
import os
34
import re
45
import subprocess
56
import sys
67
import tempfile
7-
from typing import Text
8+
from typing import Dict, List, Text
89

910
import requests
1011

@@ -21,7 +22,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
2122
dockerRequirement["dockerImageId"] = dockerRequirement["dockerPull"]
2223

2324
for ln in subprocess.check_output(
24-
["docker", "images", "--no-trunc", "--all"]).splitlines():
25+
["docker", "images", "--no-trunc", "--all"]).decode('utf-8').splitlines():
2526
try:
2627
m = re.match(r"^([^ ]+)\s+([^ ]+)\s+([^ ]+)", ln)
2728
sp = dockerRequirement["dockerImageId"].split(":")
@@ -46,7 +47,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
4647
pass
4748

4849
if not found and pull_image:
49-
cmd = [] # type: List[str]
50+
cmd = [] # type: List[Text]
5051
if "dockerPull" in dockerRequirement:
5152
cmd = ["docker", "pull", str(dockerRequirement["dockerPull"])]
5253
_logger.info(Text(cmd))
@@ -55,8 +56,8 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
5556
found = True
5657
elif "dockerFile" in dockerRequirement:
5758
dockerfile_dir = str(tempfile.mkdtemp())
58-
with open(os.path.join(dockerfile_dir, "Dockerfile"), "w") as df:
59-
df.write(dockerRequirement["dockerFile"])
59+
with open(os.path.join(dockerfile_dir, "Dockerfile"), str("w")) as df:
60+
df.write(dockerRequirement["dockerFile"].encode('utf-8'))
6061
cmd = ["docker", "build", "--tag=%s" %
6162
str(dockerRequirement["dockerImageId"]), dockerfile_dir]
6263
_logger.info(Text(cmd))
@@ -69,7 +70,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
6970
if not dry_run:
7071
if os.path.exists(dockerRequirement["dockerLoad"]):
7172
_logger.info(u"Loading docker image from %s", dockerRequirement["dockerLoad"])
72-
with open(dockerRequirement["dockerLoad"], "rb") as f:
73+
with open(dockerRequirement["dockerLoad"], str("rb")) as f:
7374
loadproc = subprocess.Popen(cmd, stdin=f, stdout=sys.stderr)
7475
else:
7576
loadproc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=sys.stderr)

cwltool/docker_uid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import print_function
2+
from __future__ import absolute_import
23

34
import subprocess
4-
from typing import Text
5+
from typing import List, Text
56

67

78
def docker_vm_uid(): # type: () -> int
@@ -91,6 +92,7 @@ def cmd_output_to_int(cmd): # type: (List[Text]) -> int
9192
except ValueError:
9293
# ValueError is raised if int conversion fails
9394
return None
95+
return None
9496

9597

9698
def boot2docker_uid(): # type: () -> int

0 commit comments

Comments
 (0)