Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
21 changes: 12 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys

FILE_ROOT = os.path.abspath(os.path.dirname(__file__))
#add the apps dir to the python path.
Expand Down Expand Up @@ -46,8 +49,8 @@
master_doc = 'index'

# General information about the project.
project = u'Sunspear'
copyright = u'2013, Numan Sachwani'
project = 'Sunspear'
copyright = '2013, Numan Sachwani'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -189,8 +192,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Sunspear.tex', u'Sunspear Documentation',
u'Numan Sachwani', 'manual'),
('index', 'Sunspear.tex', 'Sunspear Documentation',
'Numan Sachwani', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -219,8 +222,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'sunspear', u'Sunspear Documentation',
[u'Numan Sachwani'], 1)
('index', 'sunspear', 'Sunspear Documentation',
['Numan Sachwani'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -233,8 +236,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Sunspear', u'Sunspear Documentation',
u'Numan Sachwani', 'Sunspear', 'One line description of project.',
('index', 'Sunspear', 'Sunspear Documentation',
'Numan Sachwani', 'Sunspear', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
[nosetests]
where=tests

[isort]
line_length=120
known_standard_library=
known_third_party=
known_first_party=sunspear
balanced_wrapping=true
combine_star=true
# 0: grid
# 1: vertical
# 2: hanging
# 3: vert-hanging
# 4: vert-grid
# 5: vert-grid-grouped
multi_line_output=4
not_skip=__init__.py

# Don't sort one-letter classes (like Q) first
order_by_type=false

enforce_white_space=true
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python

from setuptools import setup, find_packages
from __future__ import absolute_import, division, print_function, unicode_literals

from setuptools import find_packages, setup

tests_require=[
'nose',
Expand All @@ -20,9 +22,9 @@
packages=find_packages(exclude=['tests']),
test_suite='nose.collector',
install_requires=[
'riak==2.5.4',
'python-dateutil==1.5',
'protobuf==2.6.1',
'python-dateutil>=1.5, != 2.0',
'riak',
'six',
],
options={'easy_install': {'allow_hosts': 'pypi.python.org'}},
tests_require=tests_require,
Expand Down
12 changes: 7 additions & 5 deletions sunspear/activitystreams/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from sunspear.exceptions import SunspearValidationException
from __future__ import absolute_import, division, print_function, unicode_literals

from sunspear.lib.rfc3339 import rfc3339
import datetime

import six
from dateutil.parser import parse

import datetime
from sunspear.exceptions import SunspearValidationException
from sunspear.lib.rfc3339 import rfc3339

__all__ = ('Model', 'Activity', 'ReplyActivity', 'LikeActivity',
'Object', 'MediaLink', )
Expand Down Expand Up @@ -89,7 +91,7 @@ def parse_data(self, data, *args, **kwargs):
_parsed_data[c] = _parsed_data[c].parse_data(_parsed_data[c].get_dict())

#parse anything that is a dictionary for things like datetime fields that are datetime objects
for k, v in _parsed_data.items():
for k, v in list(_parsed_data.items()):
if isinstance(v, dict) and k not in self._response_fields:
_parsed_data[k] = self.parse_data(v)

Expand All @@ -113,7 +115,7 @@ def get_dict(self):
def _parse_date(self, date=None, utc=True, use_system_timezone=False):
dt = None
if date is None or not isinstance(date, datetime.datetime):
if isinstance(date, basestring):
if isinstance(date, six.string_types):
try:
dt = parse(date)
except ValueError:
Expand Down
3 changes: 3 additions & 0 deletions sunspear/aggregators/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals


class BaseAggregator(object):
def __init__(self, *args, **kwargs):
pass
Expand Down
17 changes: 9 additions & 8 deletions sunspear/aggregators/property.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from sunspear.aggregators.base import BaseAggregator
from sunspear.lib.dotdict import dotdictify

from itertools import groupby
from __future__ import absolute_import, division, print_function, unicode_literals

import copy
import re
from itertools import groupby

from sunspear.aggregators.base import BaseAggregator
from sunspear.lib.dotdict import dotdictify


class PropertyAggregator(BaseAggregator):
Expand Down Expand Up @@ -48,12 +49,12 @@ def _listify_attributes(self, group_by_attributes=[], activity={}):
nested_root, rest = attr.split('.', 1)
#store a list of nested roots. We'll have to be careful not to listify these
nested_root_attributes.append(nested_root)
for nested_dict_key, nested_dict_value in activity.get(nested_dict).items():
for nested_dict_key, nested_dict_value in list(activity.get(nested_dict).items()):
if nested_dict_key != deepest_attr:
listified_dict['.'.join([nested_dict, nested_dict_key])] = [nested_dict_value]

#now we listify all other non nested attributes
for key, val in activity.items():
for key, val in list(activity.items()):
if key not in group_by_attributes and key not in nested_root_attributes:
listified_dict[key] = [val]

Expand Down Expand Up @@ -96,7 +97,7 @@ def _aggregate_activities(self, group_by_attributes=[], grouped_activities=[]):
#aggregate the rest of the activities into lists
for activity in group_list[1:]:
activity = dotdictify(activity)
for key in aggregated_activity.keys():
for key in list(aggregated_activity.keys()):
if key not in group_by_attributes and key not in nested_root_attributes:
aggregated_activity[key].append(activity.get(key))

Expand All @@ -107,7 +108,7 @@ def _aggregate_activities(self, group_by_attributes=[], grouped_activities=[]):
if nested_val is not None:
nested_dict, deepest_attr = attr.rsplit('.', 1)

for nested_dict_key, nested_dict_value in activity.get(nested_dict).items():
for nested_dict_key, nested_dict_value in list(activity.get(nested_dict).items()):
if nested_dict_key != deepest_attr:
aggregated_activity['.'.join([nested_dict, nested_dict_key])].append(nested_dict_value)

Expand Down
12 changes: 7 additions & 5 deletions sunspear/backends/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from sunspear.activitystreams.models import Activity, ReplyActivity, LikeActivity
from sunspear.exceptions import (SunspearDuplicateEntryException, SunspearInvalidActivityException,
SunspearInvalidObjectException)
from __future__ import absolute_import, division, print_function, unicode_literals

import uuid
import copy
import uuid

from sunspear.activitystreams.models import Activity, LikeActivity, ReplyActivity
from sunspear.exceptions import (
SunspearDuplicateEntryException, SunspearInvalidActivityException, SunspearInvalidObjectException)

__all__ = ('BaseBackend', 'SUB_ACTIVITY_MAP')

Expand Down Expand Up @@ -75,7 +77,7 @@ def create_activity(self, activity, **kwargs):

objs_created = []
objs_modified = []
for key, value in activity_copy.items():
for key, value in list(activity_copy.items()):
if key in Activity._object_fields and isinstance(value, dict):
if self.obj_exists(value):
previous_value = self.get_obj([self._extract_id(value)])[0]
Expand Down
Loading