コード例 #1
0
def iter(node):
    "Return a tree iterator"
    if isinstance(node, PandocType):
        it = __builtin__.iter(item)
    elif isinstance(node, Sequence):
        it = Sequence.iter(node)
    else: # atom
        it = __builtin__.iter([])

    yield item
    for subitem in it:
        for subsubitem in iter(subitem):
            yield subsubitem
コード例 #2
0
ファイル: pandoc.py プロジェクト: pombreda/pandoc
def iter(node):
    "Return a tree iterator"
    if isinstance(node, PandocType):
        it = __builtin__.iter(item)
    elif isinstance(node, Sequence):
        it = Sequence.iter(node)
    else: # atom
        it = __builtin__.iter([])

    yield item
    for subitem in it:
        for subsubitem in iter(subitem):
            yield subsubitem
コード例 #3
0
def md5File(fname):
    try:
        SHAhash = hashlib.md5()
        with io.open(fname, "rb") as f:
            for chunk in iter(lambda: f.read(4096), b""):
                SHAhash.update(chunk)
        return SHAhash.hexdigest()
    except:
        return '0'
コード例 #4
0
ファイル: iter.py プロジェクト: goodcrypto/goodcrypto-libs
def iter(items, sentinel=None):
    ''' A more flexible and tolerant iter().
        Accepts a single item. Treats None as an empty iterable. '''

    if items != None:
        try:
            if sentinel:
                items = takewhile(lambda x: not sentinel(x), items)
            if IS_PY2:
                for item in __builtin__.iter(items):
                    yield item
            else:
                for item in builtins.iter(items):
                    yield item
        except TypeError:
            # items is just one item
            if sentinel:
                if not sentinel(x):
                    yield items
            else:
                yield items
コード例 #5
0
ファイル: pandoc.py プロジェクト: pombreda/pandoc
def transform(node, node_map=None, type_map=None, copy=True):
    if node_map is None:
        node_map = lambda node_: node_
    if type_map is None:
        type_map = lambda type_: type_
    if copy:
        node = _copy.deepcopy(node)
        copy = False

    new_type = type_map(type(node))
    if isinstance(node, (PandocType, Sequence)):
        if isinstance(node, Sequence):
            it = Sequence.iter(node)
        else:
            it = __builtin__.iter(node)
        new_args = [transform(arg, node_map, type_map, copy) for arg in it]
        if type(new_type) is type and issubclass(new_type, Sequence):
            new_instance = new_type(new_args)
        else:
            new_instance = new_type(*new_args)
        return node_map(new_instance)
    else: # atom
        return node_map(node)
コード例 #6
0
def transform(node, node_map=None, type_map=None, copy=True):
    if node_map is None:
        node_map = lambda node_: node_
    if type_map is None:
        type_map = lambda type_: type_
    if copy:
        node = _copy.deepcopy(node)
        copy = False

    new_type = type_map(type(node))
    if isinstance(node, (PandocType, Sequence)):
        if isinstance(node, Sequence):
            it = Sequence.iter(node)
        else:
            it = __builtin__.iter(node)
        new_args = [transform(arg, node_map, type_map, copy) for arg in it]
        if type(new_type) is type and issubclass(new_type, Sequence):
            new_instance = new_type(new_args)
        else:
            new_instance = new_type(*new_args)
        return node_map(new_instance)
    else: # atom
        return node_map(node)
コード例 #7
0
ファイル: python_mod.py プロジェクト: c-mori/blaze-core
def iter(x):
    return __builtin__.iter(x)
コード例 #8
0
ファイル: pandoc.py プロジェクト: pombreda/pandoc
 def iter(sequence):
     if isinstance(sequence, dict):
         sequence = sequence.items()
     return __builtin__.iter(sequence)
コード例 #9
0
ファイル: pandoc.py プロジェクト: pombreda/pandoc
 def __iter__(self): # Maybe __iter__ should not be implemented ...
     "Return a child iterator"
     return __builtin__.iter(self.args)
コード例 #10
0
ファイル: python_mod.py プロジェクト: renjiec/blaze-core
def iter(x):
    return __builtin__.iter(x)
コード例 #11
0
ファイル: client.py プロジェクト: awood3/ioHub
 def _readServerStdOutLine(self):
     """
     Used by startServer pipe reader code. Reads a line from the ioHub server stdout. This is blocking.
     """
     for line in iter(self._server_process.stdout.readline, ''):
         yield line
コード例 #12
0
ファイル: teste.py プロジェクト: fpSpindola/LoLAPI
import urllib3
import json
import unicodedata
import re
from __builtin__ import iter
import lolapi_wrapper
import pprint

api_key = 'f905f608-0cca-4262-8c2a-ffb26d2dd246'
API_BASE_URL = 'https://br.api.pvp.net/api/lol'
#api_version = {'champion':'1.2', 'game':'1.3', 'league':'2.4', 'lol-static-data': '1.2', 'match':'2.2', 'matchhistory':'2.2','stats':'1.3', 'summoner':'1.4', 'team':'2.3'}
api_version = '1.2'
api_region = 'br'
api_url = API_BASE_URL + '/' + api_region + '/' + 'v' + api_version + '/'
season = 'SEASON4'

api_test = lolapi_wrapper.LeagueOfLegends('f905f608-0cca-4262-8c2a-ffb26d2dd246')
summoner_info_by_name = api_test.get_summoner_by_name('Stormy')

dict_values = summoner_info_by_name[next(iter(summoner_info_by_name.keys()))]

ranked_stats = api_test.get_summoner_ranked_stats(dict_values['id'], 'SEASON4')
#pprint.pprint(ranked_stats)

champions_info = api_test.get_summoner_by_name()
コード例 #13
0
 def iter(sequence):
     if isinstance(sequence, dict):
         sequence = sequence.items()
     return __builtin__.iter(sequence)
コード例 #14
0
 def __iter__(self): # Maybe __iter__ should not be implemented ...
     "Return a child iterator"
     return __builtin__.iter(self.args)
コード例 #15
0
def iter(node, tpl):
	if not node.arguments:
		raise MissingRequiredArguments(
			"Missing required argument variable at file %s, line %d" %
			(tpl.filename, node.line))
	
	if 'ival' not in tpl.node_variables:
		tpl.node_variables['ival'] = []
	if 'iindex' not in tpl.node_variables:
		tpl.node_variables['iindex'] = []
	if 'iseq' not in tpl.node_variables:
		tpl.node_variables['iseq'] = []
	if 'ikey' not in tpl.node_variables:
		tpl.node_variables['ikey'] = []
	tpl.node_variables['ival'].append(None)
	tpl.node_variables['iindex'].append(None)
	tpl.node_variables['iseq'].append(None)
	tpl.node_variables['ikey'].append(None)
	
	value = ''
	if node.arguments.startswith('ival'):
		if node.arguments == 'ival':
			value = tpl.node_variables['ival'][-2]
		else:
			# take from ival.foo.bar the foo.bar part
			args = node.arguments.split('.', 1)[1]
			if len(tpl.node_variables['ival']) >= 1:
				value = tpl.variable_value('', args, tpl.node_variables['ival'][-2])
	elif node.arguments == 'ikey':
		# iterable objects cannot be used as key in python
		raise IteratingIkey(
			"Cannot iterate over ikey at file %s, line %d" %
			(tpl.filename, node.line))
	else:
		value = tpl.variable_value(node.arguments)
	if not value:
		return ''
	tpl.node_variables['iseq'][-1] = value
	
	# check if variable is iterable
	try:
		import __builtin__ # we need this because this function is also called 'iter'
		it = __builtin__.iter(value)
	except TypeError:
		raise VariableNotIterable(
			'Variable "%s" not iterable in template "%s", at line %d' %
				(node.arguments, tpl.filename, node.line))

	evals = []
	for index, item in enumerate(value):
		tpl.node_variables['iindex'][-1] = index
		tpl.node_variables['ikey'][-1] = item
		if not isinstance(value, DictType):
			tpl.node_variables['ival'][-1] = item
		else:
			tpl.node_variables['ival'][-1] = value[item]

		evals.append(''.join([x.evaluate(tpl) for x in node.nodes]))

	tpl.node_variables['ival'].pop()
	tpl.node_variables['iindex'].pop()
	tpl.node_variables['iseq'].pop()
	tpl.node_variables['ikey'].pop()
	return ''.join(evals)
コード例 #16
0
ファイル: client.py プロジェクト: sckim/ioHub
 def _readServerStdOutLine(self):
     """
     Used by startServer pipe reader code. Reads a line from the ioHub server stdout. This is blocking.
     """
     for line in iter(self._server_process.stdout.readline, ''):
         yield line