How to use the future.utils.string_types function in future

To help you get started, we’ve selected a few future examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kensuke-Mitsuzawa / JapaneseTokenizers / test / test_juman_wrapper_python2.py View on Github external
filtered_result = juman_wrapper.filter(
            parsed_sentence=token_objects,
            pos_condition=pos_condition
        )

        assert isinstance(filtered_result, FilteredObject)
        for t_obj in filtered_result.tokenized_objects:
            assert isinstance(t_obj, TokenizedResult)
            logger.debug(u"word_surafce:{}, word_stem:{}, pos_tuple:{}, misc_info:{}".format(
                t_obj.word_surface,
                t_obj.word_stem,
                ' '.join(t_obj.tuple_pos),
                t_obj.misc_info
            ))
            assert isinstance(t_obj.word_surface, string_types)
            assert isinstance(t_obj.word_stem, string_types)
            assert isinstance(t_obj.tuple_pos, tuple)
            assert isinstance(t_obj.misc_info, dict)

            assert t_obj.tuple_pos[0] == u'名詞'

        logger.debug('-'*30)
        for stem_posTuple in filtered_result.convert_list_object():
            assert isinstance(stem_posTuple, tuple)
            word_stem = stem_posTuple[0]
            word_posTuple = stem_posTuple[1]
            assert isinstance(word_stem, string_types)
            assert isinstance(word_posTuple, tuple)

            logger.debug(u'word_stem:{} word_pos:{}'.format(word_stem, ' '.join(word_posTuple)))
github taurus-org / taurus / lib / taurus / qt / qtgui / graphic / jdraw / jdraw_view.py View on Github external
def setSelectionStyle(self, selectionStyle):
        if isinstance(selectionStyle,  string_types):
            selectionStyle = str(selectionStyle).upper()
            try:
                selectionStyle = SynopticSelectionStyle[selectionStyle]
            except:
                self.debug('invalid selectionStyle "%s"', selectionStyle)
                return
        if self.scene() is not None:
            self.setSelectionStyle(selectionStyle)
        self._selectionStyle = selectionStyle
github maparent / virtuoso-python / virtuoso / quadextractor.py View on Github external
def resolve_term(self, term, alias_maker, for_graph):
        # Options:
        # myclass.column
        # otherclass.column -> Calculate natural join
        # alias(othercls, DeferredPath).column
        # When other class involved, use that classe's base_condition.
        """Columns defined on superclass may come from another table.
        Here we calculate the necessary joins.
        Also class identity conditions for single-table inheritance
        """
        if isinstance(term, string_types + (int, Identifier)):
            return {}, term
        # TODO: Allow DeferredPaths.
        # Create conditions from paths, if needed
        # Create a variant of path link to allow upclass?
        if isinstance(term, GroundedClassAlias):
            return term
        assert _columnish(term), term.__class__.__name__
        column = term
        cls_or_alias = self.get_column_class(column)
        cls = cls_or_alias.path.final_class if isinstance(cls_or_alias, GroundedClassAlias) else cls_or_alias
        # we may be a new clone, and not have that alias.
        # Should it be copied first?
        if (isinstance(term, InstrumentedAttribute)
                and isinstance(term.class_, GroundedClassAlias)
                and cls != term.class_.path.root_cls):
            # This alias was reapplied to the aliasmaker;
github google / grr / grr / server / grr_response_server / data_stores / mysql_advanced_data_store.py View on Github external
def ResolvePrefix(self, subject, attribute_prefix, timestamp=None,
                    limit=None):
    """ResolvePrefix."""
    if isinstance(attribute_prefix, string_types):
      attribute_prefix = [attribute_prefix]

    results = []

    for prefix in attribute_prefix:
      query, args = self._BuildQuery(
          subject, prefix, timestamp, limit, is_prefix=True)
      rows, _ = self.ExecuteQuery(query, args)
      for row in sorted(rows, key=lambda x: x["attribute"]):
        attribute = row["attribute"]
        value = self._Decode(attribute, row["value"])
        results.append((attribute, value, row["timestamp"]))

    return results
github sdvillal / whatami / whatami / registry.py View on Github external
def _params2dict(ids, params, unbox_iterables, warn=False):
        """
        Helper function to allow specifying more than one record in one call to add.
        Returns a dictionary {name: param}.
        """
        if isinstance(params, dict):
            return params
        if isinstance(params, string_types):
            return {name: params for name in ids}
        if is_iterable(params) and unbox_iterables:
            if warn and len(ids) != len(params):  # pragma: no cover
                print('WARNING: number of names is different to the number of parameters (%d != %d)' %
                      (len(ids), len(params)))
            return _DefaultDict(None, **dict(zip(ids, params)))
        return _DefaultDict(default=params)
github aljungberg / pyle / pyle.py View on Github external
if word]
                        eval_locals.update({
                            'line': line,
                            'words': words,
                            'filename': in_file.name,
                            'num': num
                        })

                        out_line = eval(expr, eval_globals, eval_locals)

                        if out_line is None:
                            continue

                        # If the result is something list-like or iterable,
                        # output each item space separated.
                        if not isinstance(out_line, string_types):
                            try:
                                out_line = u' '.join(str(part) for part in out_line)
                            except:
                                # Guess it wasn't a list after all.
                                out_line = str(out_line)

                        line = out_line
                except Exception as e:
                    sys.stdout.flush()
                    sys.stderr.write("At %s:%d ('%s'): `%s`: %s\n" % (
                        in_file.name, num, truncate_ellipsis(line), expr, e))
                    if print_traceback:
                        traceback.print_exc(None, sys.stderr)
                else:
                    if out_line is None:
                        continue
github google / grr / grr / core / grr_response_core / lib / rdfvalues / artifacts.py View on Github external
def _ValidatePaths(self):
    # Catch common mistake of path vs paths.
    paths = self.attributes.GetItem("paths")
    if paths and not isinstance(paths, list):
      raise ArtifactSourceSyntaxError(self, "`paths` is not a list")

    # TODO(hanuszczak): It looks like no collector is using `path` attribute.
    # Is this really necessary?
    path = self.attributes.GetItem("path")
    if path and not isinstance(path, string_types):
      raise ArtifactSourceSyntaxError(self, "`path` is not a string")
github kolypto / py-flask-jsontools / flask_jsontools / views.py View on Github external
def __init__(self, methods=None, ifnset=None, ifset=None):
        if isinstance(methods, string_types):
            methods = (methods,)
        if isinstance(ifnset, string_types):
            ifnset = (ifnset,)
        if isinstance(ifset, string_types):
            ifset = (ifset,)

        #: Method verbs, uppercase
        self.methods = frozenset([m.upper() for m in methods]) if methods else None

        #: Conditional matching: route params that should not be set
        self.ifnset = frozenset(ifnset) if ifnset else None

        # : Conditional matching: route params that should be set
        self.ifset  = frozenset(ifset ) if ifset  else None
github buildbot / buildbot_travis / buildbot_travis / travisyml.py View on Github external
def parse_hooks(self):
        for hook in TRAVIS_HOOKS:
            commands = self.config.get(hook, [])
            if isinstance(commands, string_types):
                commands = [commands]
            if not isinstance(commands, list):
                raise TravisYmlInvalid("'%s' parameter is invalid" % hook)
            setattr(self, hook, commands)
github Kensuke-Mitsuzawa / JapaneseTokenizers / JapaneseTokenizer / datamodels.py View on Github external
assert isinstance(tuple_pos, (string_types, tuple))
        assert isinstance(word_stem, (string_types))
        assert isinstance(word_surface, text_type)
        assert isinstance(misc_info, (type(None), dict))

        self.node_obj = node_obj
        self.word_stem = word_stem
        self.word_surface = word_surface
        self.is_surface = is_surface
        self.is_feature = is_feature
        self.misc_info = misc_info
        self.analyzed_line = analyzed_line

        if isinstance(tuple_pos, tuple):
            self.tuple_pos = tuple_pos
        elif isinstance(tuple_pos, string_types):
            self.tuple_pos = ('*', )
        else:
            raise Exception('Error while parsing feature object. {}'.format(tuple_pos))