This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bar1(): | |
for x in range(4): | |
if x == 0: | |
pass | |
else: | |
# coverage thinks this line isn't covered | |
continue | |
def bar2(): | |
for x in range(4): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConsumerBindCommand(PulpCliCommand): | |
""" | |
Base class that binds a consumer to a repository and an arbitrary | |
distributor. | |
""" | |
def __init__(self, context, name=None, description=None, distributor_id=None): | |
name = name or 'bind' | |
description = description or _('binds a consumer to a repository') | |
super(self.__class__, self).__init__(name, description, self.run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sync_repo(self, repo, sync_conduit, config): | |
metadata = _fetch_repo_metadata(repo, config) | |
new_units = _resolve_units_to_download(metadata, sync_conduit) | |
def _fetch_repo_metadata(repo, config): | |
""" | |
Retrieves the listing of Puppet modules at the configured 'feed' location. | |
:return: list of modules in the external repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Migration script for existing rpm units to include repodata | |
# | |
# Copyright © 2010-2012 Red Hat, Inc. | |
# | |
# This software is licensed to you under the GNU General Public | |
# License as published by the Free Software Foundation; either version | |
# 2 of the License (GPLv2) or (at your option) any later version. | |
# There is NO WARRANTY for this software, express or implied, | |
# including the implied warranties of MERCHANTABILITY, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENCODING_LIST = ('utf8', 'iso-8859-1', 'cp1252') | |
def string_to_unicode(data, destructive=False): | |
""" | |
Make a best effort to decode a string, trying encodings in a sensible order | |
based on unscientific expectations of each one's probability of use. | |
:param data: string to decode | |
:type data: str | |
:param destructive: iff True, if all else fails, decodes as utf8 and omits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import eventlet | |
from eventlet.green import urllib2 | |
def fetch(url): | |
body = urllib2.urlopen(url).read() | |
pool = eventlet.GreenPool(15) | |
with open('files.txt') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pulp.common.download.config import DownloaderConfig | |
from pulp.common.download.request import DownloadRequest | |
from pulp.common.download.backends.curl import HTTPCurlDownloadBackend | |
with open('files.txt') as f: | |
requests = [DownloadRequest(url, url.rsplit('/', 1)[1]) for url in f.readlines()] | |
config = DownloaderConfig('http', max_concurrent=7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
version_elements = [ | |
'1', | |
'12', | |
'1a', | |
'12abc3d4ef', | |
] | |
def foo(x, y): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def paginate(iterable, page_size): | |
i = 0 | |
while True: | |
page = list(itertools.islice(iterable, i, i+page_size)) | |
if not page: | |
return | |
i = i + page_size | |
yield page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import logging | |
from pulp.common.download.config import DownloaderConfig | |
from pulp.common.download.request import DownloadRequest | |
from pulp.common.download.downloaders.event import HTTPEventletDownloader | |
logging.basicConfig() |
OlderNewer