Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cubes/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-

from __future__ import absolute_import


import os.path
from collections import defaultdict
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, roles, allowed_cubes, denied_cubes, cell_restrictions,
self.hierarchy_limits = defaultdict(list)

if hierarchy_limits:
for cube, limits in hierarchy_limits.items():
for cube, limits in list(hierarchy_limits.items()):
for limit in limits:
if isinstance(limit, compat.string_type):
limit = string_to_dimension_level(limit)
Expand Down Expand Up @@ -109,13 +109,13 @@ def merge(self, other):
self.allowed_cubes |= other.allowed_cubes
self.denied_cubes |= other.denied_cubes

for cube, restrictions in other.cell_restrictions.items():
for cube, restrictions in list(other.cell_restrictions.items()):
if not cube in self.cell_restrictions:
self.cell_restrictions[cube] = restrictions
else:
self.cell_restrictions[cube] += restrictions

for cube, limits in other.hierarchy_limits.items():
for cube, limits in list(other.hierarchy_limits.items()):
if not cube in self.hierarchy_limits:
self.hierarchy_limits[cube] = limits
else:
Expand Down Expand Up @@ -257,11 +257,11 @@ def __init__(self, rights_file=None, roles_file=None, roles=None,
raise ConfigurationError("Unknown allow/deny order: %s" % order)

# Process the roles
for key, info in roles.items():
for key, info in list(roles.items()):
role = right_from_dict(info)
self.roles[key] = role

deps = dict((name, role.roles) for name, role in self.roles.items())
deps = dict((name, role.roles) for name, role in list(self.roles.items()))
order = sorted_dependencies(deps)

for name in order:
Expand All @@ -271,7 +271,7 @@ def __init__(self, rights_file=None, roles_file=None, roles=None,
role.merge(parent)

# Process rights
for key, info in rights.items():
for key, info in list(rights.items()):
right = right_from_dict(info)
self.rights[key] = right

Expand Down
2 changes: 1 addition & 1 deletion cubes/calendar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
"""Date and time utilities."""

from __future__ import absolute_import


import re

Expand Down
18 changes: 9 additions & 9 deletions cubes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Utility functions for computing combinations of dimensions and hierarchy
levels"""

from __future__ import absolute_import


import re
import os.path
Expand Down Expand Up @@ -41,7 +41,7 @@ def set(self, key, value):

def __repr__(self):
items = []
for key, value in self.items():
for key, value in list(self.items()):
item = '%s: %s' % (repr(key), repr(value))
items.append(item)

Expand Down Expand Up @@ -120,7 +120,7 @@ def expand_dictionary(record, separator='.'):
`separator`, create sub-dictionaries as necessary"""

result = {}
for key, value in record.items():
for key, value in list(record.items()):
current = result
path = key.split(separator)
for part in path[:-1]:
Expand All @@ -143,7 +143,7 @@ def localize_attributes(attribs, translations):
keys as attribute names, values are dictionaries with localizable
attribute metadata, such as ``label`` or ``description``."""

for (name, atrans) in translations.items():
for (name, atrans) in list(translations.items()):
attrib = attribs[name]
localize_common(attrib, atrans)

Expand Down Expand Up @@ -234,7 +234,7 @@ def coalesce_options(options, types):

out = {}

for key, value in options.items():
for key, value in list(options.items()):
if key in types:
out[key] = coalesce_option_value(value, types[key], key)
else:
Expand Down Expand Up @@ -283,13 +283,13 @@ def sorted_dependencies(graph):
Will be: ``{"A": ["B"], "B": ["C", "D"], "D": ["E"],"E": []}``
"""

graph = dict((key, set(value)) for key, value in graph.items())
graph = dict((key, set(value)) for key, value in list(graph.items()))

# L ← Empty list that will contain the sorted elements
L = []

# S ← Set of all nodes with no dependencies (incoming edges)
S = set(parent for parent, req in graph.items() if not req)
S = set(parent for parent, req in list(graph.items()) if not req)

while S:
# remove a node n from S
Expand All @@ -299,7 +299,7 @@ def sorted_dependencies(graph):

# for each node m with an edge e from n to m do
# (n that depends on m)
parents = [parent for parent, req in graph.items() if n in req]
parents = [parent for parent, req in list(graph.items()) if n in req]

for parent in parents:
graph[parent].remove(n)
Expand All @@ -309,7 +309,7 @@ def sorted_dependencies(graph):
S.add(parent)

# if graph has edges then -> error
nonempty = [k for k, v in graph.items() if v]
nonempty = [k for k, v in list(graph.items()) if v]

if nonempty:
raise ArgumentError("Cyclic dependency of: %s"
Expand Down
28 changes: 14 additions & 14 deletions cubes/compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
"""Pytho compatibility utilities"""

from __future__ import absolute_import


import sys

Expand Down Expand Up @@ -34,31 +34,31 @@ def open_unicode(filename):
return open(filename, encoding="utf-8")

else:
string_type = basestring
string_type = str
binary_type = str
text_type = unicode
int_types = int, long
text_type = str
int_types = int, int

from urlparse import urlparse
from urllib2 import urlopen, build_opener
from urllib2 import HTTPPasswordMgrWithDefaultRealm
from urllib2 import HTTPBasicAuthHandler
from urllib import urlencode
from ConfigParser import SafeConfigParser as ConfigParser
from StringIO import StringIO
from Queue import Queue
from urllib.parse import urlparse
from urllib.request import urlopen, build_opener
from urllib.request import HTTPPasswordMgrWithDefaultRealm
from urllib.request import HTTPBasicAuthHandler
from urllib.parse import urlencode
from configparser import SafeConfigParser as ConfigParser
from io import StringIO
from queue import Queue
reduce = reduce

def to_str(b):
return b

def to_unicode(s):
if isinstance(s, unicode):
if isinstance(s, str):
return s
s = str(s)
for enc in ('utf8', 'latin-1'):
try:
return unicode(s, enc)
return str(s, enc)
except UnicodeDecodeError:
pass

Expand Down
2 changes: 1 addition & 1 deletion cubes/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def names(self):
self.discover()

names = list(self.builtins.keys())
names += self.extensions.keys()
names += list(self.extensions.keys())

return sorted(names)

Expand Down
4 changes: 2 additions & 2 deletions cubes/formatters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import print_function


import codecs
import csv
Expand Down Expand Up @@ -145,7 +145,7 @@ def __init__(self, iterable, separator='\n'):
def __iter__(self):
for obj in self.iterable:
string = self.encoder.encode(obj)
yield u"{}{}".format(string, self.separator)
yield "{}{}".format(string, self.separator)


class SlicerJSONEncoder(json.JSONEncoder):
Expand Down
2 changes: 1 addition & 1 deletion cubes/logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import


from logging import getLogger, Formatter, StreamHandler, FileHandler

Expand Down
2 changes: 1 addition & 1 deletion cubes/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def all_attributes(self, expand_locales=False):
"""Return a list of all attributes of a cube. If `expand_locales` is
``True``, then localized logical reference is returned for each
attribute's locale."""
return self.attributes.values()
return list(self.attributes.values())

# TODO: depreciate in favor of Cube.attribute
def attribute(self, name):
Expand Down
2 changes: 1 addition & 1 deletion cubes/metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-

from __future__ import absolute_import


from .base import *
from .attributes import *
Expand Down
8 changes: 4 additions & 4 deletions cubes/metadata/attributes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-

from __future__ import absolute_import


import copy

Expand Down Expand Up @@ -380,11 +380,11 @@ def default_aggregates(self):

for agg in self.aggregates or ["sum"]:
if agg == "identity":
name = u"%s" % self.name
name = "%s" % self.name
measure = None
function = None
else:
name = u"%s_%s" % (self.name, agg)
name = "%s_%s" % (self.name, agg)
measure = self.name
function = agg

Expand Down Expand Up @@ -588,7 +588,7 @@ def depsort_attributes(attributes, all_dependencies):
base = bases.pop()
sorted_deps.append(base)

dependants = [attr for attr, deps in remaining.items()
dependants = [attr for attr, deps in list(remaining.items())
if base in deps]

for attr in dependants:
Expand Down
2 changes: 1 addition & 1 deletion cubes/metadata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- encoding: utf-8 -*-
"""Cube logical model"""

from __future__ import absolute_import


import json
import os
Expand Down
18 changes: 9 additions & 9 deletions cubes/metadata/cube.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
"""Cube logical model"""

from __future__ import absolute_import


from collections import OrderedDict, defaultdict

Expand Down Expand Up @@ -31,12 +31,12 @@

# TODO: make this configurable
IMPLICIT_AGGREGATE_LABELS = {
"sum": u"Sum of {measure}",
"count": u"Record Count",
"count_nonempty": u"Non-empty count of {measure}",
"min": u"{measure} Minimum",
"max": u"{measure} Maximum",
"avg": u"Average of {measure}",
"sum": "Sum of {measure}",
"count": "Record Count",
"count_nonempty": "Non-empty count of {measure}",
"min": "{measure} Minimum",
"max": "{measure} Maximum",
"avg": "Average of {measure}",
}


Expand Down Expand Up @@ -584,7 +584,7 @@ def distilled_hierarchies(self):
for dim in self.dimensions:
for hier in dim.hierarchies:
key = (dim.name, hier.name)
levels = [hier_key.ref for hier_key in hier.keys()]
levels = [hier_key.ref for hier_key in list(hier.keys())]

hierarchies[key] = levels

Expand Down Expand Up @@ -806,7 +806,7 @@ def expand_cube_metadata(metadata):

if dim_hiers:
raise ModelError("There are hierarchies specified for non-linked "
"dimensions: %s." % (dim_hiers.keys()))
"dimensions: %s." % (list(dim_hiers.keys())))

nonadditive = metadata.pop("nonadditive", None)
if "measures" in metadata:
Expand Down
2 changes: 1 addition & 1 deletion cubes/metadata/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Metadata validation
"""

from __future__ import absolute_import


import pkgutil
import json
Expand Down
Loading