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
from pants.engine.addresses import Address | |
from pants.engine.fs import PathGlobs, Paths | |
from pants.engine.internals.graph import Owners, OwnersRequest | |
from pants.engine.rules import Get, UnionRule, collect_rules, rule | |
from pants.engine.target import ( | |
COMMON_TARGET_FIELDS, | |
Dependencies, | |
InjectedDependencies, | |
InjectDependenciesRequest, | |
StringSequenceField, |
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
from collections import defaultdict | |
from pathlib import Path | |
from pprint import pprint | |
import argparse | |
import ast | |
import networkx as nx | |
import os.path | |
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
from dataclasses import dataclass, field | |
import logging | |
from os.path import commonprefix | |
from typing import Sequence | |
from pants.core.goals.package import PackageFieldSet, BuiltPackage | |
from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest | |
from pants.core.target_types import FilesSources | |
from pants.engine.addresses import UnparsedAddressInputs | |
from pants.engine.fs import ( |
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
from dataclasses import dataclass | |
import logging | |
from pathlib import Path | |
from pants.core.goals.package import PackageFieldSet, BuiltPackage | |
from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest | |
from pants.core.util_rules.stripped_source_files import StrippedSourceFiles | |
from pants.engine.addresses import Address, AddressInput | |
from pants.engine.fs import EMPTY_DIGEST, MergeDigests, Snapshot | |
from pants.engine.process import ( |
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
from collections import deque | |
from typing import Generic, TypeVar, Callable, Iterable | |
T = TypeVar('T') | |
IC = TypeVar('IC') | |
OC = TypeVar('OC') | |
class ContainerTransformer(Generic[T, IC, OC]): | |
item_type : Type[T] |
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 iterable_nonstring(x): | |
"""Determines whether an object is iterable and not a string or unicode. | |
This is incorrect for python 3. | |
""" | |
return hasattr(x, '__iter__') | |
def iterable(x): | |
"""Determines whether an object can be iterated over. |
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
# Test on delivery | |
def register(key): | |
def decorator(method): | |
method.response = key | |
return method | |
return decorator | |
@register('$') |
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
@defer.inlineCallbacks | |
def retry(self, method, *args, **kwds): | |
for i in xrange(self.tries): | |
try: | |
result = yield method(*args, **kwds) | |
except: | |
if i == self.tries - 1: | |
raise | |
else: | |
defer.returnValue(result) |