Commits

Anonymous committed e7a9f02 Merge

Merging to include default

Comments (0)

Files changed (3)

keyring/util/platform.py

 platform = sys.modules['platform']
 
 def _data_root_Windows():
-	try:
-		root = os.environ['LOCALAPPDATA']
-	except KeyError:
-		# Windows XP
-		root = os.path.join(os.environ['USERPROFILE'], 'Local Settings')
-	return os.path.join(root, 'Python Keyring')
+    try:
+        root = os.environ['LOCALAPPDATA']
+    except KeyError:
+        # Windows XP
+        root = os.path.join(os.environ['USERPROFILE'], 'Local Settings')
+    return os.path.join(root, 'Python Keyring')
 
 def _data_root_Linux():
-	"""
-	Use freedesktop.org Base Dir Specfication to determine storage
-	location.
-	"""
-	fallback = os.path.expanduser('~/.local/share')
-	root = os.environ.get('XDG_DATA_HOME', None) or fallback
-	return os.path.join(root, 'python_keyring')
+    """
+    Use freedesktop.org Base Dir Specfication to determine storage
+    location.
+    """
+    fallback = os.path.expanduser('~/.local/share')
+    root = os.environ.get('XDG_DATA_HOME', None) or fallback
+    return os.path.join(root, 'python_keyring')
 
 # by default, use Unix convention
 data_root = globals().get('_data_root_' + platform.system(), _data_root_Linux)

keyring/util/properties.py

 # borrowed from jaraco.util.dictlib
 class NonDataProperty(object):
-	"""Much like the property builtin, but only implements __get__,
-	making it a non-data property, and can be subsequently reset.
+    """Much like the property builtin, but only implements __get__,
+    making it a non-data property, and can be subsequently reset.
 
-	See http://users.rcn.com/python/download/Descriptor.htm for more
-	information.
+    See http://users.rcn.com/python/download/Descriptor.htm for more
+    information.
 
-	>>> class X(object):
-	...   @NonDataProperty
-	...   def foo(self):
-	...     return 3
-	>>> x = X()
-	>>> x.foo
-	3
-	>>> x.foo = 4
-	>>> x.foo
-	4
-	"""
+    >>> class X(object):
+    ...   @NonDataProperty
+    ...   def foo(self):
+    ...     return 3
+    >>> x = X()
+    >>> x.foo
+    3
+    >>> x.foo = 4
+    >>> x.foo
+    4
+    """
 
-	def __init__(self, fget):
-		assert fget is not None, "fget cannot be none"
-		assert callable(fget), "fget must be callable"
-		self.fget = fget
+    def __init__(self, fget):
+        assert fget is not None, "fget cannot be none"
+        assert callable(fget), "fget must be callable"
+        self.fget = fget
 
-	def __get__(self, obj, objtype=None):
-		if obj is None:
-			return self
-		return self.fget(obj)
+    def __get__(self, obj, objtype=None):
+        if obj is None:
+            return self
+        return self.fget(obj)
 import collections
 
 try:
-	import keyring
+    import keyring
 except Exception:
-	pass
+    pass
 
 VERSION = '0.9.3'
 
 def get_next_version():
-	digits = map(int, VERSION.split('.'))
-	digits[-1] += 1
-	return '.'.join(map(str, digits))
+    digits = map(int, VERSION.split('.'))
+    digits[-1] += 1
+    return '.'.join(map(str, digits))
 
 NEXT_VERSION = get_next_version()
 
 files_with_versions = ('setup.py', 'release.py')
 
 def get_repo_name():
-	"""
-	Get the repo name from the hgrc default path.
-	"""
-	default = subprocess.check_output('hg paths default').strip()
-	parts = default.split('/')
-	if parts[-1] == '':
-		parts.pop()
-	return '/'.join(parts[-2:])
+    """
+    Get the repo name from the hgrc default path.
+    """
+    default = subprocess.check_output('hg paths default').strip()
+    parts = default.split('/')
+    if parts[-1] == '':
+        parts.pop()
+    return '/'.join(parts[-2:])
 
 def get_mercurial_creds(system='https://bitbucket.org', username=None):
-	"""
-	Return named tuple of username,password in much the same way that
-	Mercurial would (from the keyring).
-	"""
-	# todo: consider getting this from .hgrc
-	username = username or getpass.getuser()
-	keyring_username = '@@'.join((username, system))
-	system = '@'.join((keyring_username, 'Mercurial'))
-	password = (
-		keyring.get_password(system, keyring_username)
-		if 'keyring' in globals()
-		else None
-	)
-	if not password:
-		password = getpass.getpass()
-	Credential = collections.namedtuple('Credential', 'username password')
-	return Credential(username, password)
+    """
+    Return named tuple of username,password in much the same way that
+    Mercurial would (from the keyring).
+    """
+    # todo: consider getting this from .hgrc
+    username = username or getpass.getuser()
+    keyring_username = '@@'.join((username, system))
+    system = '@'.join((keyring_username, 'Mercurial'))
+    password = (
+        keyring.get_password(system, keyring_username)
+        if 'keyring' in globals()
+        else None
+    )
+    if not password:
+        password = getpass.getpass()
+    Credential = collections.namedtuple('Credential', 'username password')
+    return Credential(username, password)
 
 def add_milestone_and_version(version=NEXT_VERSION):
-	auth = 'Basic ' + ':'.join(get_mercurial_creds()).encode('base64').strip()
-	headers = {
-		'Authorization': auth,
-		}
-	base = 'https://api.bitbucket.org'
-	for type in 'milestones', 'versions':
-		url = (base + '/1.0/repositories/{repo}/issues/{type}'
-			.format(repo = get_repo_name(), type=type))
-		req = urllib2.Request(url = url, headers = headers,
-			data='name='+version)
-		try:
-			urllib2.urlopen(req)
-		except urllib2.HTTPError as e:
-			print(e.fp.read())
+    auth = 'Basic ' + ':'.join(get_mercurial_creds()).encode('base64').strip()
+    headers = {
+        'Authorization': auth,
+        }
+    base = 'https://api.bitbucket.org'
+    for type in 'milestones', 'versions':
+        url = (base + '/1.0/repositories/{repo}/issues/{type}'
+            .format(repo = get_repo_name(), type=type))
+        req = urllib2.Request(url = url, headers = headers,
+            data='name='+version)
+        try:
+            urllib2.urlopen(req)
+        except urllib2.HTTPError as e:
+            print(e.fp.read())
 
 def bump_versions():
-	list(map(bump_version, files_with_versions))
+    list(map(bump_version, files_with_versions))
 
 def bump_version(filename):
-	with open(filename, 'rb') as f:
-		lines = [line.replace(VERSION, NEXT_VERSION) for line in f]
-	with open(filename, 'wb') as f:
-		f.writelines(lines)
+    with open(filename, 'rb') as f:
+        lines = [line.replace(VERSION, NEXT_VERSION) for line in f]
+    with open(filename, 'wb') as f:
+        f.writelines(lines)
 
 def do_release():
-	assert all(map(os.path.exists, files_with_versions)), (
-		"Expected file(s) missing")
-	res = raw_input('Have you read through the SCM changelog and '
-		'confirmed the changelog is current for releasing {VERSION}? '
-		.format(**globals()))
-	if not res.lower().startswith('y'):
-		print("Please do that")
-		raise SystemExit(1)
+    assert all(map(os.path.exists, files_with_versions)), (
+        "Expected file(s) missing")
+    res = raw_input('Have you read through the SCM changelog and '
+        'confirmed the changelog is current for releasing {VERSION}? '
+        .format(**globals()))
+    if not res.lower().startswith('y'):
+        print("Please do that")
+        raise SystemExit(1)
 
-	res = raw_input('Have you or has someone verified that the tests '
-		'pass on this revision? ')
-	if not res.lower().startswith('y'):
-		print("Please do that")
-		raise SystemExit(2)
+    res = raw_input('Have you or has someone verified that the tests '
+        'pass on this revision? ')
+    if not res.lower().startswith('y'):
+        print("Please do that")
+        raise SystemExit(2)
 
-	subprocess.check_call(['hg', 'tag', VERSION])
+    subprocess.check_call(['hg', 'tag', VERSION])
 
-	subprocess.check_call(['hg', 'update', VERSION])
+    subprocess.check_call(['hg', 'update', VERSION])
 
-	has_docs = build_docs()
-	if os.path.isdir('./dist'):
-		shutil.rmtree('./dist')
-	cmd = [sys.executable, 'setup.py', '-q', 'egg_info', '-RD', '-b', '',
-		'sdist', 'register', 'upload']
-	if has_docs:
-		cmd.append('upload_docs')
-	subprocess.check_call(cmd)
+    has_docs = build_docs()
+    if os.path.isdir('./dist'):
+        shutil.rmtree('./dist')
+    cmd = [sys.executable, 'setup.py', '-q', 'egg_info', '-RD', '-b', '',
+        'sdist', 'register', 'upload']
+    if has_docs:
+        cmd.append('upload_docs')
+    subprocess.check_call(cmd)
 
-	# update to the tip for the next operation
-	subprocess.check_call(['hg', 'update'])
+    # update to the tip for the next operation
+    subprocess.check_call(['hg', 'update'])
 
-	# we just tagged the current version, bump for the next release.
-	bump_versions()
-	subprocess.check_call(['hg', 'ci', '-m',
-		'Bumped to {NEXT_VERSION} in preparation for next '
-		'release.'.format(**globals())])
+    # we just tagged the current version, bump for the next release.
+    bump_versions()
+    subprocess.check_call(['hg', 'ci', '-m',
+        'Bumped to {NEXT_VERSION} in preparation for next '
+        'release.'.format(**globals())])
 
-	# push the changes
-	subprocess.check_call(['hg', 'push'])
+    # push the changes
+    subprocess.check_call(['hg', 'push'])
 
-	add_milestone_and_version()
+    add_milestone_and_version()
 
 def build_docs():
-	if not os.path.isdir('docs'):
-		return
-	if os.path.isdir('docs/build'):
-		shutil.rmtree('docs/build')
-	subprocess.check_call([
-		'sphinx-build',
-		'-b', 'html',
-		'-d', 'build/doctrees',
-		'.',
-		'build/html',
-		],
-		cwd='docs')
-	return True
+    if not os.path.isdir('docs'):
+        return
+    if os.path.isdir('docs/build'):
+        shutil.rmtree('docs/build')
+    subprocess.check_call([
+        'sphinx-build',
+        '-b', 'html',
+        '-d', 'build/doctrees',
+        '.',
+        'build/html',
+        ],
+        cwd='docs')
+    return True
 
 if __name__ == '__main__':
-	do_release()
+    do_release()