Esempio n. 1
0
def convertFile(file, convertType='c'):
    readFile = ''
    if len(file) > 1:
        readFile = file[0].strip()
        convertType = file[1].strip()
    else:
        readFile = file[0].strip()
    if readFile[-3:] == 'txt':
        outfile = readFile.strip('.txt') + "_out.txt"
        print "Output File: ", outfile
        o = open(outfile, "w+")
        f = open(readFile, "r")
        f1 = f.readlines()
        for line in f1:
            if convertType == 's':
                o.write(stringcase.snakecase(line).strip('_') + '\n')
            elif convertType == 'a':
                o.write(stringcase.uppercase(line))
            elif convertType == 'l':
                o.write(stringcase.lowercase(line))
            elif convertType == 'p':
                o.write(stringcase.pascalcase(line))
            elif convertType == 'd':
                o.write(stringcase.pathcase(line).strip('/') + '\n')
            elif convertType == 'm':
                o.write(stringcase.spinalcase(line).strip('-') + '\n')
            else:
                o.write(stringcase.camelcase(stringcase.lowercase(line)))
        f.close()
        o.close()
    else:
        print 'You will need to you use a .txt'
    def test_lowercase(self):
        from stringcase import lowercase

        eq = self.assertEqual

        eq('none', lowercase(None))
        eq('', lowercase(''))
        eq('foo', lowercase('Foo'))
    def test_lowercase(self):
        from stringcase import lowercase

        eq = self.assertEqual

        eq('none', lowercase(None))
        eq('', lowercase(''))
        eq('foo', lowercase('Foo'))
 def cpp_get_namespace(self, reference) -> list:
     parts = self._get_reference_parts(reference)
     ns = copy(self.rootNs)
     if parts['pkg'] is not None:
         ns.append(stringcase.lowercase(parts['pkg']))
     else:
         ns.append(self.uri)
     ns.append(stringcase.lowercase(parts['type'].rstrip('s')))
     return ns
Esempio n. 5
0
def nameScrub(text1, text2):
	"""
	takes irregularly formatted first and last names (e.g. BOB sMiTH), converts them to lowercase, 
	and converts them again to capital case (e.g. Bob Smith) using the stringcase library returning 
	a clean full name (e.g. Bob Smith)

	"""
	fname = text1
	lname = text2
	fname = stringcase.lowercase(fname)
	fname = stringcase.capitalcase(fname)
	lname = stringcase.lowercase(lname)
	lname = stringcase.capitalcase(lname)
	fullname = fname + " " + lname + ","
	return fullname
Esempio n. 6
0
def get_attribute_list(attributes):
    atts = [{
        'name': 'id',
        'type': 'int'
    }, {
        'name': 'createdAt',
        'type': 'String'
    }]
    # convert mm data type to Dart data type
    data_types = {
        'String': 'String',
        'Int': 'int',
        'Double': 'double',
        'bool': 'bool'
    }
    for attribute in attributes:
        try:
            aname, atype = attribute['@TEXT'].split(':')
            atype = atype.lstrip()
            atype = stringcase.titlecase(atype)
            atype = data_types[atype]
        except ValueError:
            aname = attribute['@TEXT']
            atype = 'String'
        aname = stringcase.lowercase(aname)
        aname = utils.to_camel_case(aname)
        atts.append({'name': aname, 'type': atype})
    return atts
Esempio n. 7
0
    def run(self):
        """Run the pipeline"""

        # Check type
        if self.type != "package":
            error = errors.Error(
                note='For now, the only supported type is "package"')
            raise exceptions.FrictionlessException(error)

        # Import dataflows
        try:
            dataflows = import_module("dataflows")
        except ImportError:
            error = errors.Error(
                note='Please install "frictionless[dataflows]"')
            raise exceptions.FrictionlessException(error)

        # Create flow
        items = []
        for step in self.steps:
            func = getattr(dataflows, stringcase.lowercase(step["type"]))
            items.append(func(**helpers.create_options(step["spec"])))
        flow = dataflows.Flow(*items)

        # Process flow
        flow.process()
Esempio n. 8
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)
Esempio n. 9
0
 def get_result_object(self, slug, version, type):
     return {
         "slug": stringcase.lowercase(slug),
         "version": version,
         "type": type,
         "discovery_method": self.discovery_method,
         "confidence": self.confidence,
     }
Esempio n. 10
0
def create_file(model_name, attributes):
    model = utils.class_case(model_name)
    out = "class %s {\n" % model
    atts = flutter_utils.get_attribute_list(attributes)
    utils.save_model(model_name, atts)
    for att in atts:
        out += f"  {att['type']} _{att['name']};\n"

    # constructor, has comma delim except the last one
    # out += f"\n  {model}("
    # for att in atts[:-1]:
    #     out += f"this._{att['name']}, "
    # out += f"this._{atts[-1]['name']}"
    # out += ");\n\n"
    # getter

    out += f"\n  {model}();\n"

    for att in atts:
        out += f"  {att['type']} get {att['name']} => _{att['name']};\n"
    out += "\n"
    # setter
    for att in atts:
        out += f"  set {att['name']}({att['type']} {att['name']}) " + "{ "
        out += f"this._{att['name']} = {att['name']}; " + "}\n"
    out += "\n"
    # toMap
    out += "  Map<String, dynamic> toMap() {\n"
    out += "    var map = Map<String, dynamic>();\n"
    out += "    if (id != null) {\n"
    out += "      map['id'] = _id;\n"
    out += "    }\n"
    for att in atts:
        if att['name'] == 'id':
            continue
        out += f"    map['{att['name']}'] = _{att['name']};\n"
    out += "    return map;\n"
    out += "  }\n"
    out += "\n"
    # fromMap
    out += f"  {model}.fromMap( Map<String, dynamic> map) " + "{\n"
    for att in atts:
        out += f"    this._{att['name']} = map['{att['name']}'];\n"
    out += "  }\n}\n"

    # done, output to file
    filename = stringcase.lowercase(model) + '.dart'
    dst = os.path.join('lib', 'models', filename)
    with open(dst, "w") as text_file:
        text_file.write(out)
Esempio n. 11
0
 async def nick_maker(self, guild: discord.Guild, old_shit_nick):
     old_shit_nick = self.strip_accs(old_shit_nick)
     new_cool_nick = re.sub("[^a-zA-Z0-9 \n.]", "", old_shit_nick)
     new_cool_nick = " ".join(new_cool_nick.split())
     new_cool_nick = stringcase.lowercase(new_cool_nick)
     new_cool_nick = stringcase.titlecase(new_cool_nick)
     default_name = await self.config.guild(guild).new_custom_nick()
     if len(new_cool_nick.replace(" ", "")) <= 1 or len(new_cool_nick) > 32:
         if default_name == "random":
             new_cool_nick = await self.get_random_nick(2)
         elif default_name:
             new_cool_nick = default_name
         else:
             new_cool_nick = "simp name"
     return new_cool_nick
Esempio n. 12
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
Esempio n. 13
0
def _(content):
    return stringcase.lowercase(content)
Esempio n. 14
0
def lowerCaps(value):
    for value in args.lower:
        if value is not None:
            print "Lower: ", stringcase.lowercase(value)
Esempio n. 15
0
def create_file(model_name, attributes):
    app_param = utils.get_app_param()
    app_name = app_param['app_name']
    model = utils.class_case(model_name)
    model_file = stringcase.lowercase(model_name)
    model_var = stringcase.lowercase(model[0]) + model[1:]
    atts = flutter_utils.get_attribute_list(attributes)
    out = \
f'''
import 'package:sqflite/sqflite.dart';
import 'dart:async';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:{app_name}/models/{model_file}.dart';

class {model}DatabaseHelper {{
  static {model}DatabaseHelper _databaseHelper;
  static Database _database;

  String table{model} = '{model_file}';
'''
    for att in atts:
        out += f"  String col{utils.class_case(att['name'])} = '{att['name']}';\n"
    out += \
f'''
  {model}DatabaseHelper._createInstance();

  factory {model}DatabaseHelper() {{
    if (_databaseHelper == null) {{
      _databaseHelper = {model}DatabaseHelper._createInstance();
    }}
    return _databaseHelper;
  }}

  Future<Database> get database async {{
    if (_database == null) {{
      _database = await init();
    }}
    return _database;
  }}

  Future<Database> init() async {{
    Directory dir = await getApplicationDocumentsDirectory();
    String path = dir.path + '{app_name}.db';
    var db = await openDatabase(path, version: 1, onCreate: _createDatabase);
    return db;
  }}

  void _createDatabase(Database db, int version) async {{
    await db.execute('CREATE TABLE $table{model}('
      '$colId INTEGER PRIMARY KEY AUTOINCREMENT, '
'''
    db_types = {
        'string': 'TEXT',
        'int': 'INTEGER',
        'bool': 'INTEGER',
        'double': 'REAL'
    }
    for att in atts[:-1]:
        att_name = utils.class_case(att['name'])
        if att_name == 'Id':
            continue
        out += f"      '$col{att_name} {db_types[att['type'].lower()]}, '\n"
    att = atts[-1]
    out += f"      '$col{utils.class_case(att['name'])} {db_types[att['type'].lower()]} ) '\n"
    out += "    );\n"
    out += \
f'''
  }}

  Future<{model}> get{model}(int id) async {{
    Database db = await this.database;
    var result = await db.query(table{model}, where: '$colId = ?',
      whereArgs: [id]);
    return {model}.fromMap(result[0]);
  }}

  Future<List<Map<String, dynamic>>> get{model}s() async {{
    Database db = await this.database;
    var result = await db.query(table{model});
    return result;
  }}

  Future<int> insert{model}({model} {model_var}) async {{
    Database db = await this.database;
    var result = await db.insert(table{model}, {model_var}.toMap());
    return result;
  }}

  Future<int> update{model}({model} {model_var}) async {{
    Database db = await this.database;
    var result = await db.update(table{model}, {model_var}.toMap(), where: '$colId = ?',
      whereArgs: [{model_var}.id]);
    return result;
  }}

  Future<int> delete{model}(int id) async {{
    Database db = await this.database;
    int result = await db.delete(table{model}, where: '$colId = ?',
      whereArgs: [id]);
    return result;
  }}

  Future<int> getCount() async {{
    Database db = await this.database;
    List<Map<String, dynamic>> x = await db.rawQuery('SELECT COUNT(*) FROM $table{model}');
    int result = Sqflite.firstIntValue(x);
    return result;
  }}

  Future<List<{model}>> get{model}List() async {{

  var {model_var}MapList = await get{model}s();
  int count = {model_var}MapList.length;

  List<{model}> {model_var}List = List<{model}>();
  for (int i = 0; i < count; i++) {{
    {model_var}List.add({model}.fromMap({model_var}MapList[i]));
  }}

  return {model_var}List;
}}


}}
'''

    # done, output to file
    filename = stringcase.lowercase(model) + '_db.dart'
    dst = os.path.join('lib', 'models', filename)
    with open(dst, "w") as text_file:
        text_file.write(out)
Esempio n. 16
0
 def __str__(self):
     return titlecase(lowercase(self.name))