code stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 226 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k |
|---|---|---|---|---|---|
# Lint as: python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless ... | tensorflow/lingvo | docs/apidoc/conf.py | Python | apache-2.0 | 6,969 |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
import errno
import ... | fkorotkov/pants | src/python/pants/java/nailgun_client.py | Python | apache-2.0 | 7,704 |
# The name of the dashboard to be added to HORIZON['dashboards']. Required.
DASHBOARD = 'help_about'
DISABLED = False
# A list of applications to be added to INSTALLED_APPS.
ADD_INSTALLED_APPS = [
'openstack_dashboard.dashboards.help_about',
]
| ging/horizon | openstack_dashboard/enabled/_35_help_about.py | Python | apache-2.0 | 250 |
fin = open("routesRaw.txt", "r")
routes = {}
for x in fin:
xs = x.split("\t")
routeId = xs[1]
operationId = xs[2]
stepNumber = int(xs[3].replace("\n", ""))
if (routeId in routes):
routes[routeId].append(operationId)
else:
routes[routeId] = []
routes[routeId].append(operationId)
if (len(routes... | JoelBondurant/RandomCodeSamples | python/routes.py | Python | apache-2.0 | 575 |
from __future__ import print_function
import os
import ssl
import sys
import cassandra
from cassandra import auth
from cassandra.cluster import Cluster
import yaml
from cdeploy import cqlexecutor
class Migrator:
def __init__(self, migrations_path, session):
print('Reading migrations from {0}'.format(mig... | Kuwagata/cdeploy | cdeploy/migrator.py | Python | apache-2.0 | 5,863 |
#print's all prime numbers in a given range limit
_author__ = "Dilipbobby"
#Take the input from the user:
lower = int(input("Enter lower range: "))
upper = int(input("Enter upper range: "))
#condtion to print all prime numbers that are in btw given number limits
for num in range(lower,upper + 1):
if ... | dilipbobby/DataScience | Python3/Level-1/allprimes.py | Python | apache-2.0 | 457 |
#!/usr/bin/env python
import logging
import argparse, os, shutil, subprocess, sys, tempfile, time, shlex, re
import datetime
from multiprocessing import Pool
import vcf
def execute(cmd, output=None):
import subprocess, sys, shlex
# function to execute a cmd and report if an error occur
print(cmd)
try:... | jhl667/galaxy_tools | tools/pindel/pindel.py | Python | apache-2.0 | 16,775 |
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | googleapis/python-service-management | samples/generated_samples/servicemanagement_v1_generated_service_manager_create_service_sync.py | Python | apache-2.0 | 1,564 |
# -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apach... | heiths/allura | ForgeWiki/forgewiki/tests/functional/test_root.py | Python | apache-2.0 | 38,959 |
# Copyright 2020 The SQLFlow Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | sql-machine-learning/sqlflow | python/runtime/xgboost/train.py | Python | apache-2.0 | 8,174 |
# -*- coding: utf-8 -*-
from collections import defaultdict
import json
import logging
from ._compat import ElementTree, urlopen
MDN_SITEMAP = 'https://developer.mozilla.org/sitemaps/en-US/sitemap.xml'
SITEMAP_NS = 'http://www.sitemaps.org/schemas/sitemap/0.9'
log = logging.getLogger(__name__)
def parse():
"""... | malept/js-sphinx-inventory | sphinx_inventory/js/mdn.py | Python | apache-2.0 | 1,705 |
# coding=utf-8
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | google-research/tf-slim | tf_slim/layers/initializers_test.py | Python | apache-2.0 | 7,625 |
#!/usr/bin/python2.7
# Copyright 2015 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | AwesomeTurtle/personfinder | app/add_note.py | Python | apache-2.0 | 7,586 |
#!/usr/bin/python2.5
#
# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | akbertram/appengine-pipeline | src/pipeline/pipeline.py | Python | apache-2.0 | 112,693 |
from __future__ import division
from __future__ import unicode_literals
from builtins import range
from past.utils import old_div
import hashlib
import os
import random
import string
import tempfile
import re
import time
import urllib
from datetime import datetime
from datetime import timedelta
from elodie.compatabil... | jmathai/elodie | elodie/tests/helper.py | Python | apache-2.0 | 5,170 |
# Copyright 2014 Open vStorage NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | tcpcloud/openvstorage | webapps/api/backend/views/__init__.py | Python | apache-2.0 | 642 |
# Copyright 2013, Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... | cyx1231st/nova | nova/scheduler/rpcapi.py | Python | apache-2.0 | 6,665 |
@when(u'I get the text from the label')
def step_impl(context):
context.expected_text = context.page.label_id()
@when(u'I search for the label by "{how}"')
def step_impl(context, how):
method = 'label_{0}'.format(how)
context.expected_text = getattr(context.page, method)()
| OnShift/page_object | features/steps/label_steps.py | Python | apache-2.0 | 288 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name:
# Purpose: This .py file is the main Framework file
# It ranks images of a specific person of interest in a static manner
#
# Required libs: python-dateutil, numpy... | socialsensor/public-figure-image-ranking | python/mainStaticPersonTask.py | Python | apache-2.0 | 5,159 |
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | ByteInternet/libcloud | libcloud/common/nttcis.py | Python | apache-2.0 | 74,157 |
# Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | baidubce/bce-sdk-python | baidubce/services/blb/app_blb_client.py | Python | apache-2.0 | 87,381 |
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | openstack/oslo.serialization | oslo_serialization/serializer/json_serializer.py | Python | apache-2.0 | 1,376 |
"""
Functions that aid testing in various ways. A typical use would be::
lowcore = create_named_configuration('LOWBD2-CORE')
times = numpy.linspace(-3, +3, 13) * (numpy.pi / 12.0)
frequency = numpy.array([1e8])
channel_bandwidth = numpy.array([1e7])
# Define th... | SKA-ScienceDataProcessor/algorithm-reference-library | processing_components/simulation/testing_support.py | Python | apache-2.0 | 47,842 |
import json
from typing import NamedTuple
from collections import namedtuple
import kfp
import kfp.dsl as dsl
from kfp import components
from kfp.dsl.types import Integer
def get_current_namespace():
"""Returns current namespace if available, else kubeflow"""
try:
current_namespace = open(
... | kubeflow/pipelines | components/kubeflow/pytorch-launcher/sample.py | Python | apache-2.0 | 6,178 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from . import settings
from django.contrib.auth import get_user_model
def get_website_user():
"""Get a generic 'website' user.
Can be used to specify the required user when there is no direct link to
a real user.
"""
... | thecut/thecut-authorship | thecut/authorship/utils.py | Python | apache-2.0 | 551 |
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
class DmmJokeItem(Item):
# define the fields for your item here like:
# name = scrapy.Field()
pass
class DVDDetailIte... | counsellors/scrapy_dmm_dvd | dmm_joke/dmm_joke/items.py | Python | apache-2.0 | 2,040 |
import contextlib
import gc
import multiprocessing
import os
from memsql_loader.util.apsw_storage import APSWStorage
from memsql_loader.util import paths
MEMSQL_LOADER_DB = 'memsql_loader.db'
def get_loader_db_path():
return os.path.join(paths.get_data_dir(), MEMSQL_LOADER_DB)
# IMPORTANT NOTE: This class canno... | memsql/memsql-loader | memsql_loader/loader_db/storage.py | Python | apache-2.0 | 2,959 |
import zstackwoodpecker.test_state as ts_header
import os
TestAction = ts_header.TestAction
def path():
return dict(initial_formation="template5", checking_point=8, path_list=[
[TestAction.create_vm, 'vm1', ],
[TestAction.create_volume, 'volume1', 'flag=scsi'],
[TestAction.attach_volume, 'vm1', 'volume1'],
... | zstackio/zstack-woodpecker | integrationtest/vm/multihosts/vm_snapshots/paths/xsky_path23.py | Python | apache-2.0 | 1,415 |
"""
Type variables for Parametric polymorphism.
Cretonne instructions and instruction transformations can be specified to be
polymorphic by using type variables.
"""
from __future__ import absolute_import
import math
from . import types, is_power_of_two
from copy import copy
try:
from typing import Tuple, Union, ... | sunfishcode/cretonne | lib/cretonne/meta/cdsl/typevar.py | Python | apache-2.0 | 30,326 |
import itertools
from batchy.runloop import coro_return, runloop_coroutine
from batchy.batch_coroutine import batch_coroutine, class_batch_coroutine
from . import BaseTestCase
CALL_COUNT = 0
@batch_coroutine()
def increment(arg_lists):
def increment_single(n):
return n + 1
global CALL_COUNT
CAL... | mikekap/batchy | tests/batch_tests.py | Python | apache-2.0 | 4,519 |
#!/usr/bin/env python3
import docker
def pull_ncapture():
d_client = docker.from_env()
d_client.images.pull('cyberreboot/vent-ncapture', tag='master')
if __name__ == '__main__': # pragma: no cover
pull_ncapture()
| Jeff-Wang93/vent | vent/core/network_tap/ncontrol/prestart.py | Python | apache-2.0 | 230 |
# Copyright 2015 Internap.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | idjaw/netman | netman/api/api_utils.py | Python | apache-2.0 | 3,822 |
d = 1
e = 2
f = 3
| I-Valchev/UrPas | coverage-3.7.1/tests/modules/pkg1/sub/ps1a.py | Python | apache-2.0 | 18 |
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | googleapis/python-tpu | google/cloud/tpu_v2alpha1/services/tpu/async_client.py | Python | apache-2.0 | 54,857 |
# Clustalw modules
"""
A set of classes to interact with the multiple alignment command
line program clustalw.
Clustalw is the command line version of the graphical Clustalx
aligment program.
This requires clustalw available from:
ftp://ftp-igbmc.u-strasbg.fr/pub/ClustalW/.
functions:
o parse_file
o do_alignment... | dbmi-pitt/DIKB-Micropublication | scripts/mp-scripts/Bio/Clustalw/__init__.py | Python | apache-2.0 | 22,263 |
from django.shortcuts import render_to_response
from django.template import RequestContext
def index_view(request):
return render_to_response('home/index.html',
context_instance=RequestContext(request),
) | caballerojavier13/python-mda | pythonMDA/apps/home/views.py | Python | apache-2.0 | 253 |
"""The Minecraft Server sensor platform."""
from __future__ import annotations
from typing import Any
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TIME_MILLISECONDS
from homeassistant.core import HomeAssistant
from . imp... | kennedyshead/home-assistant | homeassistant/components/minecraft_server/sensor.py | Python | apache-2.0 | 5,431 |
import gc
import pprint
class Graph:
def __init__(self, name):
self.name = name
self.next = None
def set_next(self, next):
print('Linking nodes {}.next = {}'.format(self, next))
self.next = next
def __repr__(self):
return '{}({})'.format(
self.__class... | jasonwee/asus-rt-n14uhp-mrtg | src/lesson_runtime_features/gc_get_referents.py | Python | apache-2.0 | 582 |
import tensorflow as tf
"""tf.pow(x,y,name=None)
功能:计算x各元素的y次方。
输入:x,y为张量,可以为`float32`, `float64`, `int32`, `int64`,`complex64`,`complex128`类型。"""
x = tf.constant([[2, 3, 5], [2, 3, 5]], tf.float64)
y = tf.constant([[2, 3, 4]], tf.float64)
z = tf.pow(x, y)
sess = tf.Session()
print(sess.run(z))
sess.close()
"""[[ ... | Asurada2015/TFAPI_translation | math_ops_basicoperation/tf_pow.py | Python | apache-2.0 | 416 |
import numpy as np
from .VariableUnitTest import VariableUnitTest
from gwlfe.MultiUse_Fxns.Runoff import UrbRunoffLiter
class TestUrbanRunoffLiter(VariableUnitTest):
def test_UrbanRunoffLiter(self):
z = self.z
np.testing.assert_array_almost_equal(
UrbRunoffLiter.UrbRunoffLiter_f(z.NY... | WikiWatershed/gwlf-e | test/unittests/test_UrbanRunoffLiter.py | Python | apache-2.0 | 753 |
import bisect
class Solution:
def numMatchingSubseq(self, S: str, words):
d = {}
for i, x in enumerate(S):
if x not in d: d[x] = [i]
else: d[x].append(i)
ans = []
for w in words:
i = -1
result = True
for x in w:
... | zuun77/givemegoogletshirts | leetcode/python/792_number-of-matching-subsequences.py | Python | apache-2.0 | 716 |
# coding=utf-8
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
import ast
import co... | jessrosenfield/pants | src/python/pants/backend/python/tasks/checkstyle/common.py | Python | apache-2.0 | 9,330 |
# Copyright (c) 2015 Sachi King
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... | nakato/smashcache | smashcache/cache/cache.py | Python | apache-2.0 | 7,314 |
import TownLoader
import DDStreet
from toontown.suit import Suit
class DDTownLoader(TownLoader.TownLoader):
def __init__(self, hood, parentFSM, doneEvent):
TownLoader.TownLoader.__init__(self, hood, parentFSM, doneEvent)
self.streetClass = DDStreet.DDStreet
self.musicFile = 'phase_6/audio/... | silly-wacky-3-town-toon/SOURCE-COD | toontown/town/DDTownLoader.py | Python | apache-2.0 | 951 |
# 400 Nth Digit
# Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
#
# Note:
# n is positive and will fit within the range of a 32-bit signed integer (n < 231).
#
# Example 1:
#
# Input:
# 3
#
# Output:
# 3
#
# Example 2:
#
# Input:
# 11
#
# Output:
# 0
#
# Explanation:
# The ... | gengwg/leetcode | 400_nth_digit.py | Python | apache-2.0 | 1,132 |
'''
Have the function MostFreeTime(strArr) read the strArr parameter being passed
which will represent a full day and will be filled with events that span from
time X to time Y in the day. The format of each event will be
hh:mmAM/PM-hh:mmAM/PM. For example, strArr may be ["10:00AM-12:30PM",
"02:00PM-02:45PM","09:10A... | FA810/My_Codes | Python/most_free_time.py | Python | apache-2.0 | 2,924 |
from mtools.util.logevent import LogEvent
from mtools.util.input_source import InputSource
from math import ceil
from datetime import datetime
import time
import re
class LogFile(InputSource):
""" wrapper class for log files, either as open file streams of from stdin. """
def __init__(self, filehandle):
... | corymintz/mtools | mtools/util/logfile.py | Python | apache-2.0 | 10,383 |
from robot.libraries.BuiltIn import BuiltIn
def fail_with_traceback(traceback_message):
BuiltIn().fail(traceback_message)
| allure-framework/allure-python | allure-robotframework/examples/status/status_library.py | Python | apache-2.0 | 129 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under t... | celebdor/kuryr-libnetwork | kuryr_libnetwork/schemata/request_pool.py | Python | apache-2.0 | 2,102 |
# coding: utf-8
# pylint: disable= arguments-differ
"""Inception, implemented in Gluon."""
__all__ = ['Inception3', 'inception_v3']
from ....context import cpu
from ...block import HybridBlock
from ... import nn
from ..custom_layers import HybridConcurrent
# Helpers
def _make_basic_conv(**kwargs):
out = nn.Hybrid... | hesseltuinhof/mxnet | python/mxnet/gluon/model_zoo/vision/inception.py | Python | apache-2.0 | 7,902 |
import timeit
import pyximport; pyximport.install()
from mod2 import cysum, cysum2
def pysum(start, step, count):
ret = start
for i in range(count):
ret += step
return ret
print('Python',
timeit.timeit('pysum(0, 1, 100)', 'from __main__ import pysum'))
print('Cython', timeit.timeit('cysum(0... | asvetlov/optimization-kaunas-2017 | 2.py | Python | apache-2.0 | 463 |
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2015, ARM Limited and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | JaviMerino/lisa | tests/eas/hmp_parity.py | Python | apache-2.0 | 22,434 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Created as part of the StratusLab project (http://stratuslab.eu),
# co-funded by the European Commission under the Grant Agreement
# INFSO-RI-261552."
#
# Copyright (c) 2011, Centre National de la Recherche Scientifique (CNRS)
#
# Licensed under the Apache License, Vers... | StratusLab/client | cli/user/code/main/python/stratuslab/cmd/stratus_detach_volume.py | Python | apache-2.0 | 3,765 |
import re
import pscheduler
import pprint
logger = pscheduler.Log(quiet=True)
# A whole bunch of pattern matching against the output of the "iperf" tool
# client output. Builds up an object of interesting bits from it.
def parse_output(lines):
results = {}
results['succeeded'] = True
seen_header = False
... | perfsonar/pscheduler | pscheduler-tool-iperf2/iperf2/iperf2_parser.py | Python | apache-2.0 | 9,825 |
# pylint: disable=g-bad-file-header
# Copyright 2020 DeepMind Technologies Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | GoogleCloudPlatform/covid-19-open-data | src/england_data/standardize_data.py | Python | apache-2.0 | 21,282 |
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | googleads/google-ads-python | google/ads/googleads/v9/enums/types/feed_mapping_status.py | Python | apache-2.0 | 1,148 |
#
# Copyright 2016 The BigDL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | intel-analytics/BigDL | python/ppml/test/bigdl/ppml/algorithms/test_hfl_logistic_regression.py | Python | apache-2.0 | 1,167 |
# Copyright 2021 The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | GoogleCloudPlatform/opentelemetry-operations-python | opentelemetry-exporter-gcp-trace/tests/test_cloud_trace_exporter.py | Python | apache-2.0 | 28,235 |
from base import BaseClient
NURTURING_API_VERSION = '1'
class NurturingClient(BaseClient):
def _get_path(self, subpath):
return 'nurture/v%s/%s' % (NURTURING_API_VERSION, subpath)
def get_campaigns(self, **options):
return self._call('campaigns', **options)
def get_leads(self,... | ack8006/hapipy | hapi/nurturing.py | Python | apache-2.0 | 890 |
"""
def toLocal(dt, offset = 8):
dt: datetime
offset: default 8 china time
"""
import datetime
def toLocal(dt, offset = 8):
localDateTime = dt + datetime.timedelta(hours=offset)
return localDateTime
if __name__ == '__main__':
now = datetime.datetime.utcnow()
print now
print toLocal(now)
print now | pisceanfoot/py_easyXY | py_easyXY/datetime/tzone.py | Python | apache-2.0 | 309 |
#name: pygsf
#created: July 2017
#by: p.kennedy@fugro.com
#description: python module to read and write a Generic Sensor Formaty (GSF) file natively
#notes: See main at end of script for example how to use this
#based on GSF Version 3.05
# See readme.md for more details
import sys
from glob import glob
import ... | pktrigg/pygsf | pygsf.py | Python | apache-2.0 | 38,850 |
"""
Logger di varie info per ogni host
"""
from novaclient import client as novaclient
from ceilometerclient import client as ceiloclient
import os
from os import environ as env
import time
def start(hosts, sleep_sec, base_dir):
print 'You must be admin to use this script'
# start logger
time_dir = get_... | MisterPup/OpenStack-Neat-Ceilometer | alarm_test/info_logger.py | Python | apache-2.0 | 6,034 |
#! /usr/bin/python
__author__="kebo"
__date__ ="$2009-11-5 11:15:55$"
import pcap
import sys
import string
import time
import socket
import struct
import getopt
protocols={socket.IPPROTO_TCP:'tcp',
socket.IPPROTO_UDP:'udp',
socket.IPPROTO_ICMP:'icmp'}
node = None
mb = None
decoder = None
def se... | neeraj9/gprsmonitor | src/sniff.py | Python | apache-2.0 | 1,409 |
import sublime
import os
import subprocess
import platform
from .bootstrapper import get_config
from .notifier import log_info, log_error, log_fail
from .thread_progress import run_progress_indicator
from .command_thread import CommandThread
_appbuilder_path = []
def run_command(command, on_data=None, on_done=None, ... | dimitardanailov/appbuilder-sublime-package | app_builder/command_executor.py | Python | apache-2.0 | 4,567 |
from setuptools import setup, find_packages
import sys, os
version = '1.0.0'
setup(name='brica1',
version=version,
description="",
long_description="""\
""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='',
author='ktnyt',
... | wbap/V1 | python/setup.py | Python | apache-2.0 | 657 |
from __future__ import absolute_import, division, print_function, unicode_literals
from amaascore.core.amaas_model import AMaaSModel
class Reference(AMaaSModel):
def __init__(self, reference_value, reference_primary=False, *args, **kwargs):
self.reference_value = reference_value
self.reference_p... | amaas-fintech/amaas-core-sdk-python | amaascore/core/reference.py | Python | apache-2.0 | 800 |
from tensorflow.keras.applications.vgg16 import VGG16
import tensorflowjs as tfjs
model = VGG16(weights='imagenet')
tfjs.converters.save_keras_model(model, 'vgg16_tfjs')
| tensorflow/tfjs-examples | visualize-convnet/get_vgg16.py | Python | apache-2.0 | 172 |
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | ramineni/myironic | ironic/db/sqlalchemy/api.py | Python | apache-2.0 | 22,173 |
import unittest
from collections import OrderedDict
from pypika import (
Array,
Field,
JSON,
QueryException,
Table,
)
from pypika.dialects import PostgreSQLQuery
class InsertTests(unittest.TestCase):
table_abc = Table("abc")
def test_array_keyword(self):
q = PostgreSQLQuery.into(... | kayak/pypika | pypika/tests/dialects/test_postgresql.py | Python | apache-2.0 | 9,532 |
#!/usr/bin/python
#
# Copyright 2018-2021 Polyaxon, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... | polyaxon/polyaxon | core/polyaxon/utils/hashing.py | Python | apache-2.0 | 756 |
# -*- coding: utf-8 -*-
"""
Core Application - manage multiplexer connected with Analog Discovery 2
| receive voltage from sensors to estimate distance
API : wavefroms API
Author: Thatchakon Jom-ud
"""
from ctypes import *
from dwfconstants import *
import sys
import time
class Core():
hdwf = c_i... | dsjin/ThinPotApplication | core.py | Python | apache-2.0 | 3,973 |
"""
Demo platform that has two fake binary sensors.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
"""
import homeassistant.util.dt as dt_util
from homeassistant.components.calendar import CalendarEventDevice
from homeassistant.components.goog... | shaftoe/home-assistant | homeassistant/components/calendar/demo.py | Python | apache-2.0 | 2,739 |
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | iemejia/incubator-beam | sdks/python/apache_beam/runners/interactive/pipeline_fragment.py | Python | apache-2.0 | 9,582 |
import numpy as np
import shapely.affinity
import cv2
from collections import defaultdict
from shapely.geometry import MultiPolygon, Polygon
class Utils:
@staticmethod
def multi_polygon_to_pixel_mask(polygon, image_size):
mask = np.zeros(image_size, np.uint8)
int_coords = lambda x: np.array(x).round().asty... | furgerf/kaggle-projects | dstl/utils.py | Python | apache-2.0 | 2,976 |
#!/usr/bin/python
from gevent import monkey
monkey.patch_all()
import logging
import gevent
from gevent.coros import BoundedSemaphore
from kafka import KafkaClient, KeyedProducer, SimpleConsumer, common
from uveserver import UVEServer
import os
import json
import copy
import traceback
import uuid
import struct
import ... | facetothefate/contrail-controller | src/opserver/partition_handler.py | Python | apache-2.0 | 23,447 |
#!/usr/bin/env python3
from functools import partial
import math
from threading import Lock
import rospy
from geometry_msgs.msg import Twist
from lg_common.helpers import run_with_influx_exception_handler
NODE_NAME = 'mux_twists'
DEFAULT_TICK_RATE = 65.0
DEFAULT_AXIS_LIMIT = math.sqrt(2) / 2
DEFAULT_AGE_LIMIT = 1.0... | EndPointCorp/lg_ros_nodes | lg_twister/scripts/mux_twists.py | Python | apache-2.0 | 2,793 |
# coding=utf-8
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
import logging
impor... | baroquebobcat/pants | src/python/pants/pantsd/service/pailgun_service.py | Python | apache-2.0 | 4,415 |
#!/usr/bin/python
#
# Copyright 2016 Pinterest, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | pinterest/kingpin | kingpin/kazoo_utils/utils.py | Python | apache-2.0 | 1,118 |
from django.test import TestCase
from journal.tests.factories import StudentFactory
class StudentTestCase(TestCase):
"""Tests for the Student models"""
def test_student(self):
"""Test to ensure that Students can be created properly"""
student = StudentFactory.build()
self.assertEqual(... | WildCAS/CASCategorization | journal/tests/test_persons.py | Python | apache-2.0 | 353 |
"""Support for GTFS (Google/General Transport Format Schema)."""
from __future__ import annotations
import datetime
import logging
import os
import threading
from typing import Any, Callable
import pygtfs
from sqlalchemy.sql import text
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SC... | kennedyshead/home-assistant | homeassistant/components/gtfs/sensor.py | Python | apache-2.0 | 29,393 |
# -*- coding: utf-8 -*-
"""
Applied Mathematics for Computer Science.
Homework4 -- L-M Algorithm.
@author: LiBin 11531041
@date: 2016 - 5 - 23.
"""
#%% Objective: Assuming given type of the certain function
# " fun(x) = a*exp(-b*t) ", input data "x1,...x10", and output data "y1,..y10",
# using t... | tracer9/Applied_Math | Homework_4.py | Python | apache-2.0 | 3,155 |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.6.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from pprint import pformat
from six import iteritems
import re
... | skuda/client-python | kubernetes/client/models/v1_namespace_spec.py | Python | apache-2.0 | 3,316 |
# Copyright 2018, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | census-instrumentation/opencensus-python | opencensus/common/utils/__init__.py | Python | apache-2.0 | 3,607 |
# -*- coding: utf-8 -*-
'''
Created on 2015/04/17
@author: 2015 AIST
'''
import time
from django.conf import settings
from zbxsend import Metric, send_to_zabbix
import logging
import json
from vt_manager_kvm.communication.geni.v3.configurators.handlerconfigurator import HandlerConfigurator
class ZabbixHelper():
logg... | ict-felix/stack | vt_manager_kvm/src/python/vt_manager_kvm/communication/utils/ZabbixHelper.py | Python | apache-2.0 | 2,427 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/... | tomasdubec/openstack-cinder | cinder/tests/test_volume_utils.py | Python | apache-2.0 | 4,807 |
"""
config of ops service, Control by OPS devices
@author: opsdev
"""
import httplib
import json
from OpsServiceConfig import OPS_SERVICE_CONFIG
class OpsDeviceManager():
def __init__(self,config):
self.server = config["server"]
self.port = config["port"]
self.addAction = "POST"
... | HuaweiSNC/OpsDev | src/plugins/com.huawei.networkos.ops.python/templet/python/OpsDeviceManager.py | Python | apache-2.0 | 1,654 |
import unittest
from loadsbroker.db import Project, Plan, Step, Database
class DatabaseTest(unittest.TestCase):
def setUp(self):
self.db = Database('sqlite:///:memory:')
def test_project(self):
session = self.db.session()
# a project is defined by a name, a repo and strategies
... | loads/loads-broker | loadsbroker/tests/test_db.py | Python | apache-2.0 | 908 |
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
import base64
from datetime import datetime, timedelta
import functools
import json
import os
import time
import yaml
import jinja2
import jmespath
from dateutil import parser
from dateutil.tz import gettz, tzutc
try:
from botocore.exc... | thisisshi/cloud-custodian | tools/c7n_mailer/c7n_mailer/utils.py | Python | apache-2.0 | 16,298 |
"""The tests for the manual_mqtt Alarm Control Panel component."""
from datetime import timedelta
import unittest
from unittest.mock import patch
from homeassistant.setup import setup_component
from homeassistant.const import (
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_A... | persandstrom/home-assistant | tests/components/alarm_control_panel/test_manual_mqtt.py | Python | apache-2.0 | 56,123 |
# -*- coding: utf-8 -*-
'''
Uncoded Add-on
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This progr... | TheWardoctor/Wardoctors-repo | plugin.video.uncoded/uncoded.py | Python | apache-2.0 | 12,280 |
#
# Copyright (c) 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | oVirt/ovirt-engine-sdk-tests | src/utils/dictutils.py | Python | apache-2.0 | 1,025 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | DPaaS-Raksha/horizon | openstack_dashboard/dashboards/project/dashboard.py | Python | apache-2.0 | 1,678 |
# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: david@reciprocitylabs.com
# Maintained By: miha@reciprocitylabs.com
import datetime
import json
import sys
import time
from flask import current_ap... | vladan-m/ggrc-core | src/ggrc/utils.py | Python | apache-2.0 | 3,658 |
# Copyright 2009-2014 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | antonnik/code-classifier | naive_bayes/resources/python/test_pymongo.py | Python | apache-2.0 | 1,040 |
# SPDX-License-Identifer: Apache-2.0
# Copyright 2021 The Meson development team
from pathlib import Path
import pickle
from .loaderbase import LoaderBase
from .model import ReferenceManual
class LoaderPickle(LoaderBase):
def __init__(self, in_file: Path) -> None:
super().__init__()
self.in_file ... | mesonbuild/meson | docs/refman/loaderpickle.py | Python | apache-2.0 | 629 |
#
# Copyright 2011 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... | henrysher/imagefactory | imagefactory-plugins/EC2Cloud/EC2Cloud.py | Python | apache-2.0 | 70,484 |
from django.shortcuts import render
from django.views.generic import ListView
from ..cms.models import Page
from ..utils import JsonView
from .models import Original, Print
class ShopOriginalsView(ListView):
context_object_name = 'shop_items'
queryset = Original.objects.filter(disable=False).order_by('-order... | rogerhil/flaviabernardes | flaviabernardes/flaviabernardes/shop/views.py | Python | apache-2.0 | 1,517 |
#
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 by Anselm Kruis
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | akruis/pyheapdump | pyheapdump/__main__.py | Python | apache-2.0 | 3,105 |
# Copyright 2012 OpenStack Foundation.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | cboling/SDNdbg | docs/old-stuff/pydzcvr/doc/neutronclient/v2_0/client.py | Python | apache-2.0 | 54,103 |
from cloudshell.cp.vcenter.models.vCenterVMFromImageResourceModel import vCenterVMFromImageResourceModel
class DeployFromImageDetails(object):
def __init__(self, image_params, app_name):
"""
:type image_params: vCenterVMFromImageResourceModel
:type app_name: str
:return:
"... | QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/models/DeployFromImageDetails.py | Python | apache-2.0 | 396 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.