예제 #1
0
    def __init__(self,
                 name: AnyStr,
                 parent: 'Resource',
                 entry_point: 'EntryPoint',
                 title: AnyStr = None,
                 template_env=None) -> None:
        """

        :param name:
        :param parent:
        :param entry_point:
        :param title:
        :param template_env:
        """

        if not title:
            self._title = stringcase.sentencecase(name)
        else:
            self._title = title

        self._template_env = template_env
        self.__name__ = name
        self.__parent__ = parent
        self.entry_point = entry_point

        self._names = []
        self._data = {}
        self.__iter__ = lambda: self._data.__iter__()
        self.clear = lambda: self._data.clear()
        self.items = lambda: self._data.items()
        self.keys = lambda: self._data.keys()
        self.values = lambda: self._data.values()
        self.get = lambda x: self._data.get(x)
        self._entity_type = entry_point and entry_point.manager and entry_point.manager.entity_type
        self._subresource_type = Resource
예제 #2
0
    def __new__(
        cls,
        name: AnyStr,
        parent: 'Resource',
        entry_point: 'EntryPoint',
        title: AnyStr = None,
        template_env=None,
    ):
        """

        :param str name: Name of resource. This becomes the url component.
        :param Resource parent: Parent resouce. Cannot be None
        :param EntryPoint entry_point: Entry point
        :param str title: Title for resource
        :param Environment template_env: Template environment
        :return:
        """
        # fixme not thread safe
        if cls is Resource:
            count = getattr(cls, "__count__", 0)
            count = count + 1
            clsname = "%s_%04X" % (cls.__name__, count)
            setattr(cls, "__count__", count)
            meta = ResourceMeta(clsname, (cls, ), {})
            return meta(name, parent, entry_point, title, template_env)

        x = super().__new__(cls)
        if not title:
            title = stringcase.sentencecase(name)
        else:
            title = title
        x.__init__(name, parent, entry_point, title, template_env)
        return x
예제 #3
0
def normalizeBrand(keyword):
    final_word = ''
    keywordArr = keyword.split(' ')
    for key in keywordArr:
        final_word += stringcase.sentencecase(key).replace(' ', '') + ' '

    return final_word
예제 #4
0
    def convertCase(self, data):
        txt = self.txtInput.text()
        result = txt

        if data == 'Alpha Num Case':
            result = stringcase.alphanumcase(txt)
        if data == 'Camel Case':
            result = stringcase.camelcase(txt)
        if data == 'Capital Case':
            result = stringcase.capitalcase(txt)
        if data == 'Const Case':
            result = stringcase.constcase(txt)
        if data == 'Lower Case':
            result = stringcase.lowercase(txt)
        if data == 'Pascal Case':
            result = stringcase.pascalcase(txt)
        if data == 'Path Case':
            result = stringcase.pathcase(txt)
        if data == 'Sentence Case':
            result = stringcase.sentencecase(txt)
        if data == 'Snake Case':
            result = stringcase.snakecase(txt)
        if data == 'Spinal Case':
            result = stringcase.spinalcase(txt)
        if data == 'Title Case':
            result = stringcase.titlecase(txt)
        if data == 'Trim Case':
            result = stringcase.trimcase(txt)
        if data == 'Upper Case':
            result = stringcase.uppercase(txt)

        self.lblResult.setText(result)
        pyperclip.copy(result)
    def test_sentencecase(self):
        from stringcase import sentencecase

        eq = self.assertEqual
        eq('Foo bar', sentencecase('fooBar'))
        eq('Foo bar', sentencecase('foo_bar'))
        eq('Foo bar', sentencecase('foo-bar'))
        eq('Foo bar', sentencecase('foo.bar'))
        eq('Bar baz', sentencecase('_bar_baz'))
        eq('Bar baz', sentencecase('.bar_baz'))
        eq('', sentencecase(''))
        eq('None', sentencecase(None))
    def test_sentencecase(self):
        from stringcase import sentencecase

        eq = self.assertEqual
        eq('Foo bar', sentencecase('fooBar'))
        eq('Foo bar', sentencecase('foo_bar'))
        eq('Foo bar', sentencecase('foo-bar'))
        eq('Foo bar', sentencecase('foo.bar'))
        eq('Bar baz', sentencecase('_bar_baz'))
        eq('Bar baz', sentencecase('.bar_baz'))
        eq('', sentencecase(''))
        eq('None', sentencecase(None))
예제 #7
0
 def construct(self):
     h = Hierachy()
     parent = Section(accessRights=self._global_rights(),
                      name=stringcase.sentencecase(self._schema))
     h.append(parent)
     for table in self._tables.values():
         t = self._make_table(table)
         h.append(t)
         parent.children.append(t.id)
     h.set_tree()
     return h
예제 #8
0
파일: ui.py 프로젝트: libp2p/test-plans
def to_collapsible_sections(w, expanded=False):
    # build up vbox of collapsible sections
    sections = []
    for name, params in w.items():
        title = stringcase.sentencecase(name)
        children = []
        for p in params.values():
            children.append(labeled(p))

        sections.append(collapsible(title, children, expanded=expanded))
    return widgets.VBox(sections, layout={'width': '900px'})
예제 #9
0
 def sub_resource(self,
                  name: AnyStr,
                  entry_point: 'EntryPoint' = None,
                  title=None):
     logger.debug("sub_resource(%r, %r, %r)", name, entry_point, title)
     if not title:
         title = stringcase.sentencecase(name)
     sub = self._subresource_type.__new__(self._subresource_type, name,
                                          self, entry_point, title,
                                          self.template_env)
     self[name] = sub
     return sub
def get_similar_algorithms_for_algorithm(algorithm):
    """ Get a list of algorithms similar to each of a list of algorithms

    Args:
        algorithm (:obj:`str`): KiSAO id of an algorithm

    Returns:
        :obj:`list` of ``KisaoAlgorithmSubstitution``
    """
    kisao = Kisao()
    try:
        alg_term = kisao.get_term(algorithm)
    except ValueError as exception:
        raise BadRequestException(
            title='{} is not an id for a KiSAO term.'.format(algorithm),
            instance=exception,
        )
    all_alg_terms = list(kisao.get_term('KISAO_0000000').subclasses())
    if alg_term not in all_alg_terms:
        raise BadRequestException(
            title='{} is not an id for a KiSAO algorithm term.'.format(
                algorithm),
            instance=ValueError(
                '{} is not an id for a KiSAO algorithm term.'.format(
                    algorithm)),
        )

    alt_alg_policies = get_substitutable_algorithms(alg_term)

    return_value = []
    for alt_alg, policy in alt_alg_policies.items():
        return_value.append({
            "_type":
            "KisaoAlgorithmSubstitution",
            "algorithms": [{
                "_type": "KisaoTerm",
                "id": kisao.get_term_id(alg_term),
                "name": alg_term.name,
            }, {
                "_type": "KisaoTerm",
                "id": kisao.get_term_id(alt_alg),
                "name": alt_alg.name,
            }],
            "minPolicy": {
                "_type": "KisaoAlgorithmSubstitutionPolicy",
                "id": policy.name,
                "name": stringcase.sentencecase(policy.name.lower()),
                "level": ALGORITHM_SUBSTITUTION_POLICY_LEVELS[policy],
            }
        })
    return return_value
예제 #11
0
def camelcase_to_sentencecase(s: str) -> str:
    """
    Convert CamelCase to sentence case.

    Parameters
    ----------
    s: str
        Input string in CamelCase
    Returns
    -------
    str
        string in sentence case form
    """
    return stringcase.sentencecase(s).lower()
예제 #12
0
파일: kgx_utils.py 프로젝트: todun/kgx
def un_camel_case(s: str) -> str:
    """
    Convert CamelCase to normal string.

    Parameters
    ----------
    s: str
        Input string in CamelCase

    Returns
    -------
    str
        a normal string

    """
    return stringcase.sentencecase(s).lower()
예제 #13
0
def snakecase_to_sentencecase(s: str) -> str:
    """
    Convert snake_case to sentence case.

    Parameters
    ----------
    s: str
        Input string in snake_case

    Returns
    -------
    str
        a normal string

    """
    return stringcase.sentencecase(s).lower()
예제 #14
0
 def print_info(self):
     """Prints the current configuration of the pipeline. Shows the steps, dataframe paths and config paths."""
     print(f"\nPipeline Class: {self.__class__.__name__}\n")
     table = PrettyTable(["Pipeline Property", "Value"])
     table.align = "l"
     table.add_row(["Train Dataframe Path", self.train_df_path])
     table.add_row(["Test Dataframe Path", self.test_df_path])
     table.add_row(["Config File Path", self.config_file])
     table.add_row([
         "Pipeline Stages",
         ", ".join([
             stringcase.sentencecase(stage.__name__) for stage in self.steps
         ]),
     ])
     table.add_row(["Total Pipeline Stages", len(self.steps)])
     table.add_row(["Total Params", len(self.params.keys())])
     print(table)
예제 #15
0
    def case_conversion(source, style: StringStyle) -> str:
        """Case conversion of the input (usually fully qualified vss node inlcuding the path) into a supported
         string style representation.
            Args:
                source: Source string to apply conversion to.
                style: Target string style to convert source to.

            Returns:
                Converted source string according to provided string style.
         """

        if style == StringStyle.ALPHANUM_CASE:
            return stringcase.alphanumcase(source)
        elif style == StringStyle.CAMEL_CASE:
            return camel_case(source)
        elif style == StringStyle.CAMEL_BACK:
            return camel_back(source)
        elif style == StringStyle.CAPITAL_CASE:
            return stringcase.capitalcase(source)
        elif style == StringStyle.CONST_CASE:
            return stringcase.constcase(source)
        elif style == StringStyle.LOWER_CASE:
            return stringcase.lowercase(source)
        elif style == StringStyle.PASCAL_CASE:
            return stringcase.pascalcase(source)
        elif style == StringStyle.SENTENCE_CASE:
            return stringcase.sentencecase(source)
        elif style == StringStyle.SNAKE_CASE:
            return stringcase.snakecase(source)
        elif style == StringStyle.SPINAL_CASE:
            return stringcase.spinalcase(source)
        elif style == StringStyle.TITLE_CASE:
            return stringcase.titlecase(source)
        elif style == StringStyle.TRIM_CASE:
            return stringcase.trimcase(source)
        elif style == StringStyle.UPPER_CASE:
            return stringcase.uppercase(source)
        else:
            return source
예제 #16
0
    def _make_table(self, table):
        t = Table(accessRights=AccessRights(),
                  name=stringcase.sentencecase(table.name),
                  tableName=table.name,
                  schema=self._schema)
        for column in table.columns:
            t.columns.append(self._make_column(column))

        local_fks = set([fk_col.name for fk_col in table.foreign_keys])

        for relation in table.relationships:
            if relation.fk_col and relation.fk_col.name in local_fks:
                t.columns.append(self._make_linked_fk_column(relation))
                if relation.fk_col.fk.column.pk:
                    t.columns.append(self._make_hidden_pk_column(relation))
                else:
                    display_column = relation.display_column
                    if display_column is not None:
                        t.displayColumns.append(
                            DisplayColumn(rowName=self._linked_name(relation),
                                          linkRowName=display_column.name,
                                          isMultiple=False))
            else:
                t.columns.append(self._make_linked_nofk_column(relation))
                display_column = relation.display_column
                if display_column is not None:
                    t.displayColumns.append(
                        DisplayColumn(
                            rowName=self._linked_name(relation),
                            linkRowName=display_column.name,
                            isMultiple=relation.other_side.is_multiple))

        t.formDescription = t.make_form()
        t.set_default_sort()
        if t.empty:
            t.hidden = True

        return t
예제 #17
0
파일: util.py 프로젝트: yavin5/pyutrack
        def format(self, template=None, oneline=False):
            """

            :param template:
            :param oneline:
            :return:
            """
            data_source = self.fields
            if oneline:
                fields = getattr(self, '__render_min__', self.__render__)
                return '\t'.join(
                    str(data_source.get(k, getattr(self, k))) for k in fields)
            else:
                fields = template or self.__render__
                resp = ''
                for k in fields:
                    try:
                        label = stringcase.sentencecase(k).ljust(20)
                        value = data_source.get(k, getattr(self, k, None))
                        resp += "%s : %s\n" % (label, print_friendly(value))
                    except KeyError:
                        get_logger().debug("No %s attribute found for %s", k,
                                           self.__class__.__name__)
                return resp
 def name_value(self):
     return stringcase.sentencecase(self.name.lower())
예제 #19
0
    'isVisible': caster.bool_cast,
    'isUnique': caster.bool_cast,
    'isAuto': caster.bool_cast
}

_TableColumn = xmltuple(
    '_TableColumn',
    'column',
    _table_column_attrs,
    types=_table_column_types,
)

TableColumn = defaultify_init(
    _TableColumn,
    'TableColumn',
    text=lambda s: stringcase.sentencecase(s.rowName),
    isPk=False,
    isRequired=False,
    isSort=True,
    isFilter=True,
    isEditable=True,
    isUnique=False,
    isVisible=True,
    isAuto=False)

TableLinkType = xmlenum('TableLinkType',
                        'linkType',
                        SIMPLE='simple',
                        DROPDOWN='dropdown',
                        COMBINED='combined',
                        LINKED='linked')
예제 #20
0
 def class_name(cls):
     return stringcase.sentencecase(cls.__name__)
def main():
  componentPath = "../src/components"
  PComponentName = stringcase.pascalcase(componentName)
  # create a folder with component name
  path = "/home/sumit/Desktop/front-end/plugins/gtbrdd-bootstrap-vue"
  directory = path+"/src/components/"+stringcase.spinalcase(componentName)
  print(directory)
  if not os.path.exists(directory):
      os.makedirs(directory)

  # create index js file
  with open(os.path.join(directory, "index.js"), "w") as f:
    text ="""import B%s from './%s'
import { pluginFactory } from '../../utils/plugins'

const %sPlugin = /*#__PURE__*/ pluginFactory({
  components: {
    B%s
  }
})

export { %sPlugin }

export default %sPlugin
""" % (PComponentName, stringcase.spinalcase(componentName), PComponentName, PComponentName, PComponentName, PComponentName)
    f.write(text)

  # create main js file
  with open(os.path.join(directory, stringcase.spinalcase(componentName)+".js"), "w") as f:
    text = """import %s from './%s.vue'

export default {
  name: 'B%s',
  render: h => h(%s)
}
""" % (PComponentName, stringcase.spinalcase(componentName), PComponentName, PComponentName)
    f.write(text)

  # create main vue file
  with open(os.path.join(directory, stringcase.spinalcase(componentName)+".vue"), "w") as f:
    text = """<template>
  <div id="%s">
  </div>
</template>

<script>
export default {
  name: '%s',
  components: {},
  props: {
    steps: {
      type: Array,
      default: function() {
        return []
      }
    }
  },
  data() {
    return {
      temp: null
    }
  }
}
</script>
""" % (stringcase.spinalcase(componentName), PComponentName)
    f.write(text)

  # create package.json file
  with open(os.path.join(directory, "package.json"), "w") as f:
    text = """{
  "name": "@bootstrap-vue/%s",
  "version": "1.0.0",
  "meta": {
    "title": "%s",
    "description": "Group a series of buttons together on a single line with <b-%s>.",
    "components": [
      {
        "component": "B%s"
      }
    ]
  }
}
""" % (stringcase.spinalcase(componentName), stringcase.sentencecase(componentName), stringcase.spinalcase(componentName), PComponentName)
    f.write(text)

  with open(os.path.join(directory, "README.md"), "w") as f:
    text = "# "+ stringcase.sentencecase(componentName)
    f.write(text)
  # edit index esm
  esm_path = path+"/src/components/index.esm.js"
  with open(esm_path, "r") as f:
    lines = f.readlines()
    text = '// first block\n'
    i = lines.index(text)
    lines.insert(i+1, "import { "+PComponentName+"Plugin } from './"+stringcase.spinalcase(componentName)+"'\n")
    text = '// second block\n'
    i = lines.index(text)
    lines.insert(i+1, "export { "+PComponentName+"Plugin } from './"+stringcase.spinalcase(componentName)+"'\n")
    text = '    // fourth block\n'
    i = lines.index(text)
    lines.insert(i+1, "    "+PComponentName+"Plugin,\n")

  with open(esm_path, "w") as f:
    f.writelines(lines)

  index_path = path+"/src/components/index.js"
  with open(index_path, "r") as f:
    lines = f.readlines()
    text = '// third block\n'
    i = lines.index(text)
    lines.insert(i+1, "export { "+PComponentName+"Plugin as "+PComponentName+" } from './"+stringcase.spinalcase(componentName)+"'\n")
  with open(index_path, "w") as f:
      f.writelines(lines)
예제 #22
0
def sentence_case(value):
    return stringcase.sentencecase(value)
예제 #23
0
파일: GenUtils.py 프로젝트: oreon/textgen
 def humanize( str):
     return stringcase.sentencecase(str)
예제 #24
0
    from Tkinter import Tk
except ImportError:
    from tkinter import Tk


in_tmp = "xxx"
in_tmp = "xxx"
in_tmp = "xxx"
in_tmp = "xxx"
in_tmp = "xxx"
in_tmp = "xxx"
in_tmp = "sign_up_procedure"



# https://pypi.org/project/stringcase/
copy_to_clipboard = False

if copy_to_clipboard:
  r = Tk()
  r.withdraw()
  r.clipboard_clear()
  r.clipboard_append('i can has clipboardz?')
  r.update() # now it stays on the clipboard after the window is closed
  r.destroy()

out_tmp_snakecase = stringcase.snakecase(in_tmp)
out_tmp_sentencecase = stringcase.sentencecase(in_tmp)

print("\n\n"+out_tmp_snakecase+"\n\n")
print("\n\n"+out_tmp_sentencecase+"\n\n")
예제 #25
0
def format_metric(key, value):
    formatted_key = stringcase.sentencecase(key)
    return f"*{formatted_key}:* {value}"
예제 #26
0
def title_sentence_case(s):
    return stringcase.sentencecase(s).title()