mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
More Py2 hacks
This commit is contained in:
parent
7646222bc7
commit
d6787892e8
2 changed files with 11 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ from .utils import CliError, JobFailed, cli_logger, coerce_native, \
|
||||||
save_status, storage_class_from_config, storage_instance_from_config
|
save_status, storage_class_from_config, storage_instance_from_config
|
||||||
|
|
||||||
from ..sync import sync
|
from ..sync import sync
|
||||||
|
from ..utils.compat import to_unicode
|
||||||
|
|
||||||
|
|
||||||
def prepare_pair(wq, pair_name, collections, config, callback, **kwargs):
|
def prepare_pair(wq, pair_name, collections, config, callback, **kwargs):
|
||||||
|
|
@ -21,6 +22,9 @@ def prepare_pair(wq, pair_name, collections, config, callback, **kwargs):
|
||||||
# spawn one worker less because we can reuse the current one
|
# spawn one worker less because we can reuse the current one
|
||||||
new_workers = -1
|
new_workers = -1
|
||||||
for collection_name in (collections or all_collections):
|
for collection_name in (collections or all_collections):
|
||||||
|
# XXX: PY2 hack
|
||||||
|
if collection_name is not None:
|
||||||
|
collection_name = to_unicode(collection_name, 'utf-8')
|
||||||
try:
|
try:
|
||||||
config_a, config_b = all_collections[collection_name]
|
config_a, config_b = all_collections[collection_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,13 @@ class Storage(with_metaclass(StorageMeta)):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.instance_name or '<{}(**{})>'.format(
|
try:
|
||||||
|
if self.instance_name:
|
||||||
|
return str(self.instance_name)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return '<{}(**{})>'.format(
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
dict((x, getattr(self, x)) for x in self._repr_attributes)
|
dict((x, getattr(self, x)) for x in self._repr_attributes)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue