repo_name
stringlengths
5
100
path
stringlengths
4
254
copies
stringlengths
1
5
size
stringlengths
4
7
content
stringlengths
733
1M
license
stringclasses
15 values
hash
int64
-9,223,351,895,964,839,000
9,223,354,783B
line_mean
float64
3.5
100
line_max
int64
15
1k
alpha_frac
float64
0.25
0.96
autogenerated
bool
1 class
ratio
float64
1.5
8.15
config_test
bool
2 classes
has_no_keywords
bool
2 classes
few_assignments
bool
1 class
ahmedbodi/AutobahnPython
examples/asyncio/websocket/echo/client_coroutines.py
13
2044
############################################################################### ## ## Copyright (C) 2013-2014 Tavendo GmbH ## ## 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 the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## ############################################################################### from autobahn.asyncio.websocket import WebSocketClientProtocol, \ WebSocketClientFactory import asyncio class MyClientProtocol(WebSocketClientProtocol): def onConnect(self, response): print("Server connected: {0}".format(response.peer)) @asyncio.coroutine def onOpen(self): print("WebSocket connection open.") ## start sending messages every second .. while True: self.sendMessage(u"Hello, world!".encode('utf8')) self.sendMessage(b"\x00\x01\x03\x04", isBinary = True) yield from asyncio.sleep(1) def onMessage(self, payload, isBinary): if isBinary: print("Binary message received: {0} bytes".format(len(payload))) else: print("Text message received: {0}".format(payload.decode('utf8'))) def onClose(self, wasClean, code, reason): print("WebSocket connection closed: {0}".format(reason)) if __name__ == '__main__': import asyncio factory = WebSocketClientFactory("ws://localhost:9000", debug = False) factory.protocol = MyClientProtocol loop = asyncio.get_event_loop() coro = loop.create_connection(factory, '127.0.0.1', 9000) loop.run_until_complete(coro) loop.run_forever() loop.close()
apache-2.0
7,822,061,744,094,950,000
31.444444
79
0.623288
false
4.214433
false
false
false
ifduyue/django
django/core/checks/registry.py
13
3108
from itertools import chain from django.utils.itercompat import is_iterable class Tags: """ Built-in tags for internal checks. """ admin = 'admin' caches = 'caches' compatibility = 'compatibility' database = 'database' models = 'models' security = 'security' signals = 'signals' templates = 'templates' urls = 'urls' class CheckRegistry: def __init__(self): self.registered_checks = set() self.deployment_checks = set() def register(self, check=None, *tags, **kwargs): """ Can be used as a function or a decorator. Register given function `f` labeled with given `tags`. The function should receive **kwargs and return list of Errors and Warnings. Example:: registry = CheckRegistry() @registry.register('mytag', 'anothertag') def my_check(apps, **kwargs): # ... perform checks and collect `errors` ... return errors # or registry.register(my_check, 'mytag', 'anothertag') """ kwargs.setdefault('deploy', False) def inner(check): check.tags = tags checks = self.deployment_checks if kwargs['deploy'] else self.registered_checks checks.add(check) return check if callable(check): return inner(check) else: if check: tags += (check, ) return inner def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False): """ Run all registered checks and return list of Errors and Warnings. """ errors = [] checks = self.get_checks(include_deployment_checks) if tags is not None: checks = [check for check in checks if not set(check.tags).isdisjoint(tags)] else: # By default, 'database'-tagged checks are not run as they do more # than mere static code analysis. checks = [check for check in checks if Tags.database not in check.tags] for check in checks: new_errors = check(app_configs=app_configs) assert is_iterable(new_errors), ( "The function %r did not return a list. All functions registered " "with the checks registry must return a list." % check) errors.extend(new_errors) return errors def tag_exists(self, tag, include_deployment_checks=False): return tag in self.tags_available(include_deployment_checks) def tags_available(self, deployment_checks=False): return set(chain.from_iterable( check.tags for check in self.get_checks(deployment_checks) )) def get_checks(self, include_deployment_checks=False): checks = list(self.registered_checks) if include_deployment_checks: checks.extend(self.deployment_checks) return checks registry = CheckRegistry() register = registry.register run_checks = registry.run_checks tag_exists = registry.tag_exists
bsd-3-clause
-2,035,686,896,372,967,700
30.714286
91
0.602317
false
4.433666
false
false
false
kmike/scikit-learn
sklearn/utils/__init__.py
3
10094
""" The :mod:`sklearn.utils` module includes various utilites. """ from collections import Sequence import numpy as np from scipy.sparse import issparse import warnings from .murmurhash import murmurhash3_32 from .validation import (as_float_array, check_arrays, safe_asarray, assert_all_finite, array2d, atleast2d_or_csc, atleast2d_or_csr, warn_if_not_float, check_random_state) from .class_weight import compute_class_weight __all__ = ["murmurhash3_32", "as_float_array", "check_arrays", "safe_asarray", "assert_all_finite", "array2d", "atleast2d_or_csc", "atleast2d_or_csr", "warn_if_not_float", "check_random_state", "compute_class_weight"] # Make sure that DeprecationWarning get printed warnings.simplefilter("always", DeprecationWarning) class deprecated(object): """Decorator to mark a function or class as deprecated. Issue a warning when the function is called/the class is instantiated and adds a warning to the docstring. The optional extra argument will be appended to the deprecation message and the docstring. Note: to use this with the default value for extra, put in an empty of parentheses: >>> from sklearn.utils import deprecated >>> deprecated() # doctest: +ELLIPSIS <sklearn.utils.deprecated object at ...> >>> @deprecated() ... def some_function(): pass """ # Adapted from http://wiki.python.org/moin/PythonDecoratorLibrary, # but with many changes. def __init__(self, extra=''): """ Parameters ---------- extra: string to be added to the deprecation messages """ self.extra = extra def __call__(self, obj): if isinstance(obj, type): return self._decorate_class(obj) else: return self._decorate_fun(obj) def _decorate_class(self, cls): msg = "Class %s is deprecated" % cls.__name__ if self.extra: msg += "; %s" % self.extra # FIXME: we should probably reset __new__ for full generality init = cls.__init__ def wrapped(*args, **kwargs): warnings.warn(msg, category=DeprecationWarning) return init(*args, **kwargs) cls.__init__ = wrapped wrapped.__name__ = '__init__' wrapped.__doc__ = self._update_doc(init.__doc__) wrapped.deprecated_original = init return cls def _decorate_fun(self, fun): """Decorate function fun""" msg = "Function %s is deprecated" % fun.__name__ if self.extra: msg += "; %s" % self.extra def wrapped(*args, **kwargs): warnings.warn(msg, category=DeprecationWarning) return fun(*args, **kwargs) wrapped.__name__ = fun.__name__ wrapped.__dict__ = fun.__dict__ wrapped.__doc__ = self._update_doc(fun.__doc__) return wrapped def _update_doc(self, olddoc): newdoc = "DEPRECATED" if self.extra: newdoc = "%s: %s" % (newdoc, self.extra) if olddoc: newdoc = "%s\n\n%s" % (newdoc, olddoc) return newdoc def safe_mask(X, mask): """Return a mask which is safe to use on X. Parameters ---------- X : {array-like, sparse matrix} Data on which to apply mask. mask: array Mask to be used on X. Returns ------- mask """ mask = np.asanyarray(mask) if np.issubdtype(mask.dtype, np.int): return mask if hasattr(X, "toarray"): ind = np.arange(mask.shape[0]) mask = ind[mask] return mask def resample(*arrays, **options): """Resample arrays or sparse matrices in a consistent way The default strategy implements one step of the bootstrapping procedure. Parameters ---------- `*arrays` : sequence of arrays or scipy.sparse matrices with same shape[0] replace : boolean, True by default Implements resampling with replacement. If False, this will implement (sliced) random permutations. n_samples : int, None by default Number of samples to generate. If left to None this is automatically set to the first dimension of the arrays. random_state : int or RandomState instance Control the shuffling for reproducible behavior. Returns ------- Sequence of resampled views of the collections. The original arrays are not impacted. Examples -------- It is possible to mix sparse and dense arrays in the same run:: >>> X = [[1., 0.], [2., 1.], [0., 0.]] >>> y = np.array([0, 1, 2]) >>> from scipy.sparse import coo_matrix >>> X_sparse = coo_matrix(X) >>> from sklearn.utils import resample >>> X, X_sparse, y = resample(X, X_sparse, y, random_state=0) >>> X array([[ 1., 0.], [ 2., 1.], [ 1., 0.]]) >>> X_sparse # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE <3x2 sparse matrix of type '<... 'numpy.float64'>' with 4 stored elements in Compressed Sparse Row format> >>> X_sparse.toarray() array([[ 1., 0.], [ 2., 1.], [ 1., 0.]]) >>> y array([0, 1, 0]) >>> resample(y, n_samples=2, random_state=0) array([0, 1]) See also -------- :class:`sklearn.cross_validation.Bootstrap` :func:`sklearn.utils.shuffle` """ random_state = check_random_state(options.pop('random_state', None)) replace = options.pop('replace', True) max_n_samples = options.pop('n_samples', None) if options: raise ValueError("Unexpected kw arguments: %r" % options.keys()) if len(arrays) == 0: return None first = arrays[0] n_samples = first.shape[0] if hasattr(first, 'shape') else len(first) if max_n_samples is None: max_n_samples = n_samples if max_n_samples > n_samples: raise ValueError("Cannot sample %d out of arrays with dim %d" % ( max_n_samples, n_samples)) arrays = check_arrays(*arrays, sparse_format='csr') if replace: indices = random_state.randint(0, n_samples, size=(max_n_samples,)) else: indices = np.arange(n_samples) random_state.shuffle(indices) indices = indices[:max_n_samples] resampled_arrays = [] for array in arrays: array = array[indices] resampled_arrays.append(array) if len(resampled_arrays) == 1: # syntactic sugar for the unit argument case return resampled_arrays[0] else: return resampled_arrays def shuffle(*arrays, **options): """Shuffle arrays or sparse matrices in a consistent way This is a convenience alias to ``resample(*arrays, replace=False)`` to do random permutations of the collections. Parameters ---------- `*arrays` : sequence of arrays or scipy.sparse matrices with same shape[0] random_state : int or RandomState instance Control the shuffling for reproducible behavior. n_samples : int, None by default Number of samples to generate. If left to None this is automatically set to the first dimension of the arrays. Returns ------- Sequence of shuffled views of the collections. The original arrays are not impacted. Examples -------- It is possible to mix sparse and dense arrays in the same run:: >>> X = [[1., 0.], [2., 1.], [0., 0.]] >>> y = np.array([0, 1, 2]) >>> from scipy.sparse import coo_matrix >>> X_sparse = coo_matrix(X) >>> from sklearn.utils import shuffle >>> X, X_sparse, y = shuffle(X, X_sparse, y, random_state=0) >>> X array([[ 0., 0.], [ 2., 1.], [ 1., 0.]]) >>> X_sparse # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE <3x2 sparse matrix of type '<... 'numpy.float64'>' with 3 stored elements in Compressed Sparse Row format> >>> X_sparse.toarray() array([[ 0., 0.], [ 2., 1.], [ 1., 0.]]) >>> y array([2, 1, 0]) >>> shuffle(y, n_samples=2, random_state=0) array([0, 1]) See also -------- :func:`sklearn.utils.resample` """ options['replace'] = False return resample(*arrays, **options) def safe_sqr(X, copy=True): """Element wise squaring of array-likes and sparse matrices. Parameters ---------- X : array like, matrix, sparse matrix Returns ------- X ** 2 : element wise square """ X = safe_asarray(X) if issparse(X): if copy: X = X.copy() X.data **= 2 else: if copy: X = X ** 2 else: X **= 2 return X def gen_even_slices(n, n_packs): """Generator to create n_packs slices going up to n. Examples -------- >>> from sklearn.utils import gen_even_slices >>> list(gen_even_slices(10, 1)) [slice(0, 10, None)] >>> list(gen_even_slices(10, 10)) #doctest: +ELLIPSIS [slice(0, 1, None), slice(1, 2, None), ..., slice(9, 10, None)] >>> list(gen_even_slices(10, 5)) #doctest: +ELLIPSIS [slice(0, 2, None), slice(2, 4, None), ..., slice(8, 10, None)] >>> list(gen_even_slices(10, 3)) [slice(0, 4, None), slice(4, 7, None), slice(7, 10, None)] """ start = 0 for pack_num in range(n_packs): this_n = n // n_packs if pack_num < n % n_packs: this_n += 1 if this_n > 0: end = start + this_n yield slice(start, end, None) start = end def tosequence(x): """Cast iterable x to a Sequence, avoiding a copy if possible.""" if isinstance(x, np.ndarray): return np.asarray(x) elif isinstance(x, Sequence): return x else: return list(x) class ConvergenceWarning(Warning): "Custom warning to capture convergence problems"
bsd-3-clause
2,334,709,577,611,160,600
26.883978
79
0.56806
false
3.874856
false
false
false
houlixin/BBB-TISDK
linux-devkit/sysroots/i686-arago-linux/usr/lib/python2.7/encodings/cp1250.py
593
13942
""" Python Character Mapping Codec cp1250 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='cp1250', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\u20ac' # 0x80 -> EURO SIGN u'\ufffe' # 0x81 -> UNDEFINED u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK u'\ufffe' # 0x83 -> UNDEFINED u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS u'\u2020' # 0x86 -> DAGGER u'\u2021' # 0x87 -> DOUBLE DAGGER u'\ufffe' # 0x88 -> UNDEFINED u'\u2030' # 0x89 -> PER MILLE SIGN u'\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK u'\u015a' # 0x8C -> LATIN CAPITAL LETTER S WITH ACUTE u'\u0164' # 0x8D -> LATIN CAPITAL LETTER T WITH CARON u'\u017d' # 0x8E -> LATIN CAPITAL LETTER Z WITH CARON u'\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE u'\ufffe' # 0x90 -> UNDEFINED u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK u'\u2022' # 0x95 -> BULLET u'\u2013' # 0x96 -> EN DASH u'\u2014' # 0x97 -> EM DASH u'\ufffe' # 0x98 -> UNDEFINED u'\u2122' # 0x99 -> TRADE MARK SIGN u'\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK u'\u015b' # 0x9C -> LATIN SMALL LETTER S WITH ACUTE u'\u0165' # 0x9D -> LATIN SMALL LETTER T WITH CARON u'\u017e' # 0x9E -> LATIN SMALL LETTER Z WITH CARON u'\u017a' # 0x9F -> LATIN SMALL LETTER Z WITH ACUTE u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\u02c7' # 0xA1 -> CARON u'\u02d8' # 0xA2 -> BREVE u'\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE u'\xa4' # 0xA4 -> CURRENCY SIGN u'\u0104' # 0xA5 -> LATIN CAPITAL LETTER A WITH OGONEK u'\xa6' # 0xA6 -> BROKEN BAR u'\xa7' # 0xA7 -> SECTION SIGN u'\xa8' # 0xA8 -> DIAERESIS u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xac' # 0xAC -> NOT SIGN u'\xad' # 0xAD -> SOFT HYPHEN u'\xae' # 0xAE -> REGISTERED SIGN u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE u'\xb0' # 0xB0 -> DEGREE SIGN u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\u02db' # 0xB2 -> OGONEK u'\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE u'\xb4' # 0xB4 -> ACUTE ACCENT u'\xb5' # 0xB5 -> MICRO SIGN u'\xb6' # 0xB6 -> PILCROW SIGN u'\xb7' # 0xB7 -> MIDDLE DOT u'\xb8' # 0xB8 -> CEDILLA u'\u0105' # 0xB9 -> LATIN SMALL LETTER A WITH OGONEK u'\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u013d' # 0xBC -> LATIN CAPITAL LETTER L WITH CARON u'\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT u'\u013e' # 0xBE -> LATIN SMALL LETTER L WITH CARON u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE u'\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE u'\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS u'\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX u'\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE u'\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX u'\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xd7' # 0xD7 -> MULTIPLICATION SIGN u'\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON u'\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE u'\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE u'\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S u'\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS u'\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE u'\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS u'\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE u'\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf7' # 0xF7 -> DIVISION SIGN u'\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON u'\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE u'\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE u'\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA u'\u02d9' # 0xFF -> DOT ABOVE ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-2.0
-6,356,832,018,515,183,000
44.413681
119
0.550351
false
3.023639
false
false
false
dataxu/ansible
lib/ansible/modules/system/kernel_blacklist.py
125
4009
#!/usr/bin/python # encoding: utf-8 -*- # Copyright: (c) 2013, Matthias Vogelgesang <[email protected]> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: kernel_blacklist author: - Matthias Vogelgesang (@matze) version_added: '1.4' short_description: Blacklist kernel modules description: - Add or remove kernel modules from blacklist. options: name: description: - Name of kernel module to black- or whitelist. required: true state: description: - Whether the module should be present in the blacklist or absent. choices: [ absent, present ] default: present blacklist_file: description: - If specified, use this blacklist file instead of C(/etc/modprobe.d/blacklist-ansible.conf). ''' EXAMPLES = ''' - name: Blacklist the nouveau driver module kernel_blacklist: name: nouveau state: present ''' import os import re from ansible.module_utils.basic import AnsibleModule class Blacklist(object): def __init__(self, module, filename, checkmode): self.filename = filename self.module = module self.checkmode = checkmode def create_file(self): if not self.checkmode and not os.path.exists(self.filename): open(self.filename, 'a').close() return True elif self.checkmode and not os.path.exists(self.filename): self.filename = os.devnull return True else: return False def get_pattern(self): return r'^blacklist\s*' + self.module + '$' def readlines(self): f = open(self.filename, 'r') lines = f.readlines() f.close() return lines def module_listed(self): lines = self.readlines() pattern = self.get_pattern() for line in lines: stripped = line.strip() if stripped.startswith('#'): continue if re.match(pattern, stripped): return True return False def remove_module(self): lines = self.readlines() pattern = self.get_pattern() if self.checkmode: f = open(os.devnull, 'w') else: f = open(self.filename, 'w') for line in lines: if not re.match(pattern, line.strip()): f.write(line) f.close() def add_module(self): if self.checkmode: f = open(os.devnull, 'a') else: f = open(self.filename, 'a') f.write('blacklist %s\n' % self.module) f.close() def main(): module = AnsibleModule( argument_spec=dict( name=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), blacklist_file=dict(type='str') ), supports_check_mode=True, ) args = dict(changed=False, failed=False, name=module.params['name'], state=module.params['state']) filename = '/etc/modprobe.d/blacklist-ansible.conf' if module.params['blacklist_file']: filename = module.params['blacklist_file'] blacklist = Blacklist(args['name'], filename, module.check_mode) if blacklist.create_file(): args['changed'] = True else: args['changed'] = False if blacklist.module_listed(): if args['state'] == 'absent': blacklist.remove_module() args['changed'] = True else: if args['state'] == 'present': blacklist.add_module() args['changed'] = True module.exit_json(**args) if __name__ == '__main__': main()
gpl-3.0
8,498,771,084,445,727,000
24.864516
92
0.575206
false
4.017034
false
false
false
163gal/Time-Line
libs_arm/wx/_controls.py
2
332374
"# This file was created automatically by SWIG 1.3.29.\n# Don't modify this file, modify the SWIG in(...TRUNCATED)
gpl-3.0
-3,839,353,247,363,315,700
41.465057
151
0.65503
false
3.857592
false
false
false
blackbliss/callme
flask/lib/python2.7/site-packages/werkzeug/contrib/cache.py
306
23519
"# -*- coding: utf-8 -*-\n\"\"\"\n werkzeug.contrib.cache\n ~~~~~~~~~~~~~~~~~~~~~~\n\n The (...TRUNCATED)
mit
-7,111,811,701,270,589,000
33.637703
86
0.579106
false
4.281631
false
false
false
pipet/pipet
pipet/sources/zendesk/tasks.py
2
1544
"from contextlib import contextmanager\nfrom datetime import datetime\nfrom inspect import isclass\n(...TRUNCATED)
apache-2.0
156,606,072,465,059,940
28.692308
96
0.645725
false
4.084656
false
false
false
prutseltje/ansible
test/units/modules/network/f5/test_bigip_gtm_datacenter.py
23
6819
"# -*- coding: utf-8 -*-\n#\n# Copyright (c) 2017 F5 Networks Inc.\n# GNU General Public License v3.(...TRUNCATED)
gpl-3.0
1,435,203,684,349,960,200
30.716279
91
0.628685
false
4.235404
true
false
false
antb/TPT----My-old-mod
src/python/stdlib/ctypes/test/test_errno.py
115
2330
"import unittest, os, errno\nfrom ctypes import *\nfrom ctypes.util import find_library\nfrom test i(...TRUNCATED)
gpl-2.0
785,952,512,028,991,400
28.125
69
0.554077
false
3.782468
true
false
false
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

CodeParrot 🦜 Dataset Cleaned and filtered (train)

Dataset Description

A dataset of Python files from Github. It is a more filtered version of the train split codeparrot-clean-train of codeparrot-clean. The additional filters aim at detecting configuration and test files, as well as outlier files that are unlikely to help the model learn code. The first three filters are applied with a probability of 0.7:

  • files with a mention of "test file" or "configuration file" or similar in the first 5 lines
  • files with high occurence of the keywords "test " or "config"
  • files without a mention of the keywords def, for, while and class
  • files that use the assignment operator = less than 5 times
  • files with ratio between number of characters and number of tokens after tokenization < 1.5
Downloads last month
453
Edit dataset card