This file contains hidden or 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
| """ | |
| https://github.com/docker/docker/blob/master/pkg/namesgenerator/names-generator.go | |
| """ | |
| from random import choice | |
| ADJECTIVES=["admiring","adoring","affectionate","agitated","amazing","angry","awesome","blissful","boring","brave","clever","cocky","compassionate","competent","condescending","confident","cranky","dazzling","determined","distracted","dreamy","eager","ecstatic","elastic","elated","elegant","eloquent","epic","fervent","festive","flamboyant","focused","friendly","frosty","gallant","gifted","goofy","gracious","happy","hardcore","heuristic","hopeful","hungry","infallible","inspiring","jolly","jovial","keen","kickass","kind","laughing","loving","lucid","mystifying","modest","musing","naughty","nervous","nifty","nostalgic","objective","optimistic","peaceful","pedantic","pensive","practical","priceless","quirky","quizzical","relaxed","reverent","romantic","sad","serene","sharp","silly","sleepy","stoic","stupefied","suspicious","tender","thirsty","trusting","unruffled","upbeat","vibrant","vigilant","w |
This file contains hidden or 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 pytest | |
| from collections import OrderedDict | |
| from pprint import pprint | |
| @pytest.hookimpl(trylast=True) | |
| def pytest_collection_modifyitems(session, config, items): | |
| """ | |
| Create an ordered dict containing clustered tests based on classes |
This file contains hidden or 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 NodeFactory(object): | |
| @staticmethod | |
| def create(node_type): | |
| if node_type == 'SANode': | |
| return SANode | |
| else: | |
| return Node |
This file contains hidden or 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 collections | |
| from pprint import pprint as pp | |
| from copy import copy | |
| smp = {'nine': {'eee': True, 'fff': {'ooo': 3, 'type': 'hsm'}, 'type': 'pc'}, | |
| 'one': {'bar': 6, 'foo': 5}, | |
| 'two': {'four': {'bar': 3, 'zzz': 3, 'type': 'g5', 'ge': {'v': 3}}, 'three': {'bar': 9, 'zzz': 9}}} | |
| def find_resource_type(item): |
This file contains hidden or 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 pprint | |
| import random | |
| def weighted_random(weights): | |
| number = random.random() * sum(weights.values()) | |
| for k, v in weights.iteritems(): | |
| if number < v: | |
| break | |
| number -= v |
This file contains hidden or 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 remove_from_console(console, log, levels=['DEBUG']): | |
| to_remove = [x for x in log if x['level'] in levels] | |
| skip_lines = 0 | |
| console_filtered = [] | |
| for index, line in enumerate(console): | |
| if skip_lines: | |
| skip_lines -= 1 | |
| continue |
This file contains hidden or 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 binascii | |
| import glob | |
| char_count = 32 | |
| for filename in glob.glob('f7w*'): | |
| with open(filename, 'rb') as f, open(filename + '.txt', 'w') as output: | |
| data = binascii.hexlify(f.read()) | |
| for i, line in enumerate([data[i:i+char_count] for i in range(0, len(data), char_count)]): | |
| if i % 4 == 0: |
This file contains hidden or 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 MockClassicConnection(object): | |
| """Mock classic RPyC connection object. Useful when you want the same code to run remotely or locally. | |
| """ | |
| def __init__(self): | |
| self._conn = None | |
| self.namespace = {} | |
| self.modules = ModuleNamespace(self.getmodule) | |
| if is_py3k: | |
| self.builtin = self.modules.builtins |
This file contains hidden or 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 ipdb | |
| import pytest | |
| from collections import Mapping | |
| PARTITION_NAME = 'PARTITION' | |
| PARTITION_PASSWORD = 'PASSWORD' | |
| @pytest.fixture(scope='class') | |
| def computer_resource(request): |
This file contains hidden or 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
| tracked_languages = ['persian', 'lithuanian', 'ukrainian', 'romanian', 'vietnamese', 'slovak', 'bulgarian', 'slovenian', | |
| 'hebrew', 'arabic', 'serbian', 'turkish', 'estonian', 'icelandic', 'thai', 'korean', 'hungarian', | |
| 'russian', 'latin', 'czech', 'truefrench', 'japanese', 'chinese', 'portuguese', 'polish', | |
| 'finnish', 'norwegian', 'flemish', 'nordic', 'danish', 'swedish', 'dutch', 'spanish', 'italian', | |
| 'french', 'german'] |
NewerOlder