function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def get_provider_fields(provider):
return get_provider_field_map().get(provider) | frappe/frappe | [
4495,
2418,
4495,
1493,
1307520856
] |
def patch(self):
math_libs = self.spec['lapack'].libs + self.spec['blas'].libs
makefile = FileFilter('Makefile')
if self.spec.satisfies('%gcc'):
makefile.filter(r'^MKL\s+=\s1', 'MKL=0')
makefile.filter(r'^CC\s+=\sgcc',
'CC={0}'.format(spack_cc)... | LLNL/spack | [
3244,
1839,
3244,
2847,
1389172932
] |
def testFromSparseTensorSlices(self, slices):
"""Test a dataset based on slices of a `tf.sparse.SparseTensor`."""
st = array_ops.sparse_placeholder(dtypes.float64)
iterator = dataset_ops.make_initializable_iterator(
dataset_ops.Dataset.from_sparse_tensor_slices(st))
init_op = iterator.initialize... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def testFromSparseTensorSlicesInReverse(self, slices):
"""Test a dataset based on slices of a `tf.sparse.SparseTensor` in reverse order."""
st = array_ops.sparse_placeholder(dtypes.float64)
iterator = dataset_ops.make_initializable_iterator(
dataset_ops.Dataset.from_sparse_tensor_slices(st))
ini... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def testEmptySparseTensorSlices(self):
"""Test a dataset based on slices of an empty `tf.sparse.SparseTensor`."""
st = array_ops.sparse_placeholder(dtypes.float64)
iterator = dataset_ops.make_initializable_iterator(
dataset_ops.Dataset.from_sparse_tensor_slices(st))
init_op = iterator.initialize... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def testEmptySparseTensorSlicesInvalid(self):
"""Test a dataset based on invalid `tf.sparse.SparseTensor`."""
st = array_ops.sparse_placeholder(dtypes.float64)
iterator = dataset_ops.make_initializable_iterator(
dataset_ops.Dataset.from_sparse_tensor_slices(st))
init_op = iterator.initializer
... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def testEmptySparseTensorSlicesInvalid2(self):
"""Test a dataset based on invalid `tf.sparse.SparseTensor`."""
st = array_ops.sparse_placeholder(dtypes.float64)
iterator = dataset_ops.make_initializable_iterator(
dataset_ops.Dataset.from_sparse_tensor_slices(st))
init_op = iterator.initializer
... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def testFromSparseTensorSlicesError(self):
with self.assertRaises(AttributeError):
dataset_ops.Dataset.from_sparse_tensor_slices(None) | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def _build_sparse_tensor_slice_dataset(self, slices):
# pylint: disable=g-complex-comprehension
indices = np.array(
[[i, j] for i in range(len(slices)) for j in range(len(slices[i]))],
dtype=np.int64)
values = np.array([val for s in slices for val in s], dtype=np.float64)
# pylint: enabl... | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def test(self, verify_fn):
slices = [[1., 2., 3.], [1.], [1.], [1., 2.], [], [1., 2.], [], [], []]
verify_fn(
self,
lambda: self._build_sparse_tensor_slice_dataset(slices),
num_outputs=9,
sparse_tensors=True) | tensorflow/tensorflow | [
171949,
87931,
171949,
2300,
1446859160
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
review_request = context['review_request']
... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
return (context['review_request'].public and
... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
return (context['perms']['reviews']['delete_r... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
review_request = context['review_request']
... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def get_label(self, context):
"""Return this action's label.
The label will change depending on whether or not the corresponding
review request already has a diff.
Args:
context (django.template.Context):
The collection of key-value pairs from the template.
... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def get_url(self, context):
"""Return this action's URL.
Args:
context (django.template.Context):
The collection of key-value pairs from the template.
Returns:
unicode: The URL to invoke if this action is clicked.
"""
match = context['req... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether or not this action should render.
Args:
context (django.template.Context):
The collection of key-value pairs available in the template
just before this action is to be rendered.
Returns:
... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
user = context['request'].user
retur... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
request = context['request']
user = r... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def should_render(self, context):
"""Return whether the action should render.
Args:
context (dict):
The current render context.
Returns:
bool:
Whether the action should render.
"""
user = context['request'].user
return... | reviewboard/reviewboard | [
1464,
419,
1464,
1,
1250977189
] |
def setUp(self):
pass | talon-one/talon_one.py | [
1,
3,
1,
1,
1484929786
] |
def make_instance(self, include_optional):
"""Test UpdateLoyaltyProgram
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = talon_one.models.update_loyalty_program.UpdateLoya... | talon-one/talon_one.py | [
1,
3,
1,
1,
1484929786
] |
def __init__(self, plotly_name="hoverlabel", parent_name="sankey", **kwargs):
super(HoverlabelValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_class_str=kwargs.pop("data_class_str", "Hoverlabel"),
data_docs=kwargs.pop(
... | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def recognize_business_card(self):
path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__),
"..", "..", "./sample_forms/business_cards/business-card-english.jpg"))
# [START recognize_business_cards]
from azure.core... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def test_config(self):
with self.test_session():
loss = LeastSquaresLoss(mock_gan(), loss_config)
self.assertTrue(loss.config.test) | 255BITS/HyperGAN | [
1175,
170,
1175,
20,
1466808596
] |
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def begin_create_or_update(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
parameters, # type: "_models.LocalNetworkGateway"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('LocalNetworkGateway', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def _delete_initial(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def begin_delete(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def _update_tags_initial(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
parameters, # type: "_models.TagsObject"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def begin_update_tags(
self,
resource_group_name, # type: str
local_network_gateway_name, # type: str
parameters, # type: "_models.TagsObject"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('LocalNetworkGateway', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list(
self,
resource_group_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadat... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=resp... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_acco... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def schedule_single_message(sender):
message = ServiceBusMessage("Message to be scheduled")
scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)
sequence_number = sender.schedule_messages(message, scheduled_time_utc)
return sequence_number | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def main():
servicebus_client = ServiceBusClient.from_connection_string(
conn_str=CONNECTION_STR, logging_enable=True
)
with servicebus_client:
sender = servicebus_client.get_topic_sender(topic_name=TOPIC_NAME)
with sender:
sequence_number = schedule_single_message(sender... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def main(): | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def annotate_old_bird_calls(): | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def create_raw_df(rows): | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def create_aggregate_df(df): | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def sum_counts(df, detector): | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def add_precision_recall_f1(df):
p = df['Old Bird Calls'] / df['Old Bird Clips']
r = df['Old Bird Calls'] / df['Ground Truth Calls']
df['Precision'] = to_percent(p)
df['Recall'] = to_percent(r)
df['F1'] = to_percent(2 * p * r / (p + r)) | HaroldMills/Vesper | [
43,
3,
43,
33,
1398351334
] |
def test_survey_publication_date_views(self):
"""We have some views to display and set the published column
for a survey session
"""
with api.env.adopt_user("admin"):
survey = addSurvey(self.portal, BASIC_SURVEY)
account = addAccount(password="secret")
survey_... | euphorie/Euphorie | [
11,
5,
11,
6,
1303204650
] |
def device(portnum):
"""Turn a port number into a device name"""
#the "//./COMx" format is required for devices >= 9
#not all versions of windows seem to support this propperly
#so that the first few ports are used with the DOS device name
if portnum < 9:
return 'COM%d' % (portnum+1) #number... | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def open(self):
"""Open port with current settings. This may throw a SerialException
if the port cannot be opened."""
if self._port is None:
raise SerialException("Port must be configured before it can be used.")
self.hComPort = None
try:
self.hComPort ... | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def _reconfigurePort(self):
"""Set commuication parameters on opened port."""
if not self.hComPort:
raise SerialException("Can only operate on a valid port handle") | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def close(self):
"""Close port"""
if self._isOpen:
if self.hComPort:
#Restore original timeout values:
win32file.SetCommTimeouts(self.hComPort, self._orgTimeouts)
#Close COM-Port:
win32file.CloseHandle(self.hComPort)
... | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def inWaiting(self):
"""Return the number of characters currently in the input buffer."""
flags, comstat = win32file.ClearCommError(self.hComPort)
return comstat.cbInQue | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def write(self, s):
"""Output the given string over the serial port."""
if not self.hComPort: raise portNotOpenError
#print repr(s),
if s:
err, n = win32file.WriteFile(self.hComPort, s, self._overlappedWrite)
if err: #will be ERROR_IO_PENDING:
# Wa... | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def flushOutput(self):
"""Clear output buffer, aborting the current output and
discarding all that is in the buffer."""
if not self.hComPort: raise portNotOpenError
win32file.PurgeComm(self.hComPort, win32file.PURGE_TXCLEAR | win32file.PURGE_TXABORT) | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def setRTS(self,level=1):
"""Set terminal status line: Request To Send"""
if not self.hComPort: raise portNotOpenError
if level:
win32file.EscapeCommFunction(self.hComPort, win32file.SETRTS)
else:
win32file.EscapeCommFunction(self.hComPort, win32file.CLRRTS) | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def getCTS(self):
"""Read terminal status line: Clear To Send"""
if not self.hComPort: raise portNotOpenError
return MS_CTS_ON & win32file.GetCommModemStatus(self.hComPort) != 0 | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def getRI(self):
"""Read terminal status line: Ring Indicator"""
if not self.hComPort: raise portNotOpenError
return MS_RING_ON & win32file.GetCommModemStatus(self.hComPort) != 0 | emilydolson/forestcat | [
2,
2,
2,
2,
1370887123
] |
def test_serialize(self):
# Valid room
data = SensorSerializer.serialize(SensorDTO(id=1, name='foo', room=5),
fields=['id', 'name', 'room'])
self.assertEqual({'id': 1,
'name': 'foo',
'room': 5}, data)
... | openmotics/gateway | [
30,
12,
30,
27,
1481877206
] |
def update_product_by_location(self, cr, uid, context=None):
context = context or self.pool['res.users'].context_get(cr, uid)
location_ids = self.search(cr, uid, [('update_product_bylocation', '=', True)], context=context)
location_vals = {}
start_time = datetime.now()
date_produ... | iw3hxn/LibrERP | [
29,
16,
29,
1,
1402418161
] |
def _get_original_image_url(self, px=1024):
return "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Gullfoss%2C_an_iconic_waterfall_of_Iceland.jpg/{}px-Gullfoss%2C_an_iconic_waterfall_of_Iceland.jpg".format(
px
) | yelizariev/addons-yelizariev | [
33,
79,
33,
2,
1465301317
] |
def __init__(self, resource):
self.resource = resource | yaybu/touchdown | [
11,
4,
11,
17,
1410353271
] |
def pending(self, runner, object):
provisioner = runner.get_service(self.resource.provisioner, "apply")
return provisioner.object["Result"] == "Pending" | yaybu/touchdown | [
11,
4,
11,
17,
1410353271
] |
def __init__(self, resource):
self.resource = resource | yaybu/touchdown | [
11,
4,
11,
17,
1410353271
] |
def pending(self, runner, object):
provisioner = runner.get_service(self.resource.provisioner, "apply")
return provisioner.object["Result"] == "Pending" | yaybu/touchdown | [
11,
4,
11,
17,
1410353271
] |
def __init__(self,
channel=LocalChannel(),
nodes_per_block=1,
cores_per_block=None,
cores_per_node=None,
init_blocks=1,
min_blocks=0,
max_blocks=1,
parallelism=1,
wall... | Parsl/parsl | [
369,
114,
369,
333,
1476980871
] |
def submit(self, command, tasks_per_node, job_name="parsl.lsf"):
"""Submit the command as an LSF job.
Parameters
----------
command : str
Command to be made on the remote side.
tasks_per_node : int
Command invocations to be launched per node
job_n... | Parsl/parsl | [
369,
114,
369,
333,
1476980871
] |
def get_metadata(self):
"""Returns the current metadata as a dictionary.""" | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def exponential_draw(lambdax):
scale = 1.0 / lambdax
return exponential(scale=scale,size=None) | ThomasBrouwer/BNMTF | [
18,
6,
18,
1,
1438595414
] |
def test_on_device_via_string():
x = relay.Var("x")
call = relay.annotation.on_device(x, "cuda")
assert isinstance(call, relay.Call)
assert len(call.args) == 1
assert call.args[0] == x
assert call.attrs.virtual_device.device_type_int == 2 # ie kDLCUDA
assert call.attrs.virtual_device.virtua... | dmlc/tvm | [
9142,
2938,
9142,
595,
1476310828
] |
def test_on_device_invalid_device():
x = relay.Var("x")
pytest.raises(ValueError, lambda: relay.annotation.on_device(x, "bogus")) | dmlc/tvm | [
9142,
2938,
9142,
595,
1476310828
] |
def test_on_device_free():
x = relay.Var("x")
call = relay.annotation.on_device(x, "cuda", constrain_result=False, constrain_body=False)
assert call.attrs.virtual_device.device_type_int == -1 # ie kInvalidDeviceType
assert not call.attrs.constrain_body
assert not call.attrs.constrain_result | dmlc/tvm | [
9142,
2938,
9142,
595,
1476310828
] |
def tokenize(self, text):
raise NotImplementedError("Tokenizer must override tokenize() method") | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def __init__(self, use_stemmer=False):
"""Constructor for DefaultTokenizer.
Args:
use_stemmer: boolean, indicating whether Porter stemmer should be used to
strip word suffixes to improve matching.
"""
self._stemmer = porter.PorterStemmer() if use_stemmer else None | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def __init__(self, action: str = None) -> None:
super().__init__(prefix, action) | cloudtools/awacs | [
386,
98,
386,
14,
1364415387
] |
def __init__(self, resource: str = "", region: str = "", account: str = "") -> None:
super().__init__(
service=prefix, resource=resource, region=region, account=account
) | cloudtools/awacs | [
386,
98,
386,
14,
1364415387
] |
def RunSteps(api):
url = 'https://chromium.googlesource.com/chromium/src.git'
# git.checkout can optionally dump GIT_CURL_VERBOSE traces to a log file,
# useful for debugging git access issues that are reproducible only on bots.
curl_trace_file = None
if api.properties.get('use_curl_trace'):
curl_trace_f... | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def set_home(home):
""" Set Home """
# This module should be refactored into object to avoid the anti-pattern global statement
global CONFIG_PATH, CACHE_PATH, SHARE_PATH
CONFIG_PATH = os.path.join(home, "config")
CACHE_PATH = os.path.join(home, "cache")
SHARE_PATH = os.path.join(home, "share") | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def get_cache_path(*args):
"""
Get a config path to read or write some cached data
:param args: a list of subfolders. Those will be created when needed
"""
return get_path(CACHE_PATH, *args) | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def get_path(*args):
""" Helper for get_*_path methods """
full_path = os.path.join(*args)
to_make = os.path.dirname(full_path)
mkdir(to_make, recursive=True)
full_path = to_native_path(full_path)
return full_path | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def mkdir(dest_dir, recursive=False):
""" Recursive mkdir (do not fail if file exists) """
try:
if recursive:
os.makedirs(dest_dir)
else:
os.mkdir(dest_dir)
except OSError as exc:
if exc.errno != 17:
raise
# Directory already exists -> no e... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def write_file_if_different(data, out_path, mode="w"):
""" Write the data to out_path if the content is different """
try:
with open(out_path, "r") as outr:
out_prev = outr.read()
if out_prev == data:
ui.debug("skipping write to %s: same content" % (out_path))
... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def _copy_link(src, dest, quiet):
""" Copy Link """
if not os.path.islink(src):
raise Exception("%s is not a link!" % src)
target = os.readlink(src) # pylint:disable=no-member
# remove existing stuff
if os.path.lexists(dest):
rm(dest)
if sys.stdout.isatty() and not quiet:
... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def _handle_files(src, dest, root, files, filter_fun, quiet):
""" Helper function used by install() """
installed = list()
rel_root = os.path.relpath(root, src)
if rel_root == ".":
rel_root = ""
new_root = os.path.join(dest, rel_root)
for f in files:
if not filter_fun(os.path.joi... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def no_filter_fun(_unused):
""" Filter Function Always True """
return True | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def safe_copy(src, dest):
"""
Copy a source file to a destination but
do not overwrite dest if it is more recent than src
Create any missing directories when necessary
If dest is a directory, src will be copied inside dest.
"""
if os.path.isdir(dest):
dest = os.path.join(dest, os.pat... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def copy_git_src(src, dest):
"""
Copy a source to a destination but only copy the files under version control.
Assumes that ``src`` is inside a git worktree
"""
process = subprocess.Popen(["git", "ls-files", "."], cwd=src,
stdout=subprocess.PIPE)
(out, _) = process... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def rmtree(path):
"""
shutil.rmtree() on steroids.
Taken from gclient source code (BSD license)
Recursively removes a directory, even if it's marked read-only.
shutil.rmtree() doesn't work on Windows if any of the files or directories
are read-only, which svn repositories and some .svn files are... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def ls_r(directory):
"""
Returns a sorted list of all the files present in a directory,
relative to this directory.
For instance, with::
foo
|__ eggs
| |__ c
| |__ d
|__ empty
|__ spam
|__a
|__b
ls_r(foo) returns:
["eg... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def to_posix_path(path, fix_drive=False):
"""
Returns a POSIX path from a DOS path
:param fix_drive: if True, will replace c: by /c/ (ala mingw)
"""
res = os.path.expanduser(path)
res = os.path.abspath(res)
res = path.replace(ntpath.sep, posixpath.sep)
if fix_drive:
(drive, rest)... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def to_native_path(path, normcase=True):
"""
Return an absolute, native path from a path,
:param normcase: make sure the path is all lower-case on
case-insensitive filesystems
"""
path = os.path.expanduser(path)
if normcase:
path = os.path.normcase(path)
path = os.path.normpath(p... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def is_empty(path):
""" Check if a path is empty """
return os.listdir(path) == list() | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def __init__(self, name="tmp"):
""" TempDir Init """
self._temp_dir = tempfile.mkdtemp(prefix=name + "-") | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def __exit__(self, _type, value, tb):
""" Exit """
if os.environ.get("DEBUG"):
if tb is not None:
print("==")
print("Not removing ", self._temp_dir)
print("==")
return
rm(self._temp_dir) | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def change_cwd(directory):
""" Change the current working dir """
if not os.path.exists(directory):
mess = "Cannot change working dir to '%s'\n" % directory
mess += "This path does not exist"
raise Exception(mess)
previous_cwd = os.getcwd()
os.chdir(directory)
yield
os.ch... | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def broken_symlink(file_path):
""" Returns True if the file is a broken symlink """
return os.path.lexists(file_path) and not os.path.exists(file_path) | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def is_executable_binary(file_path):
"""
Returns true if the file:
* is executable
* is a binary (i.e not a script)
"""
if not os.path.isfile(file_path):
return False
if not os.access(file_path, os.X_OK):
return False
return is_binary(file_path) | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def __init__(self, path):
""" Preserve file metadata of 'path' """
self.path = path
self.time = None
self.mode = None | aldebaran/qibuild | [
67,
45,
67,
42,
1297185497
] |
def extractRoontalesCom(item):
'''
Parser for 'roontales.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('PRC', 'PRC', 'translated'),
('Loiterous', 'Loiterous', ... | fake-name/ReadableWebProxy | [
191,
16,
191,
3,
1437712243
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.