def main():
    """
    for each locale json file reads the file parsing it to json and insert the data into the database
    :return: None
    """
    first_time = True
    for id_locale, locale in LOCALES.items():
        with open("runes{}.json".format(locale)) as inputfile:
            response = json.load(inputfile)

        try:
            runes_version = session.query(Configuration).filter_by(
                code="{} version".format(response['type'])).one()
        except:
            configdata = {
                "code": "{} version".format(response['type']),
                "value": response['version']
            }
            print("añadiendo versión runas")
            runes_version = Configuration(**configdata)
            session.add(runes_version)

        if runes_version.value != response['version']:
            runes_version.version = response['version']
            session.add(runes_version)

        runes_data = response['data']

        for runes in runes_data.values():
            if first_time:
                data = {
                    "id": runes['id'],
                    "tier": runes['rune']['tier'],
                    "type": runes['rune']['type'],
                    "tags": ','.join(runes['tags']),
                    "image": runes['image']['full']
                }
                newSummSpell = Runes(**data)
                session.add(newSummSpell)

            translation = {
                "id_rune": runes['id'],
                "id_language": id_locale,
                "name": runes['name'],
                "description": runes['sanitizedDescription']
            }
            newTranslation = RunesTranslations(**translation)
            session.add(newTranslation)

        first_time = False
        print("todos los datos insertados con éxito para {}".format(locale))

    session.commit()
def main():
    """
    for each locale json file reads the file parsing it to json and insert the data into the database
    :return: None
    """
    first_time = True
    for id_locale, locale in LOCALES.items():
        with open("{}.json".format(locale)) as inputfile:
            response = json.load(inputfile)

        try:
            masteryversion = session.query(Configuration).filter_by(
                code="{} version".format(response['type'])).one()
        except:
            configdata = {
                "code": "{} version".format(response['type']),
                "value": response['version']
            }
            print("añadiendo versión maestrias")
            masteryversion = Configuration(**configdata)
            session.add(masteryversion)

        if masteryversion.value != response['version']:
            masteryversion.version = response['version']
            session.add(masteryversion)

        masteries_data = response['data']

        for mastery in masteries_data.values():
            # champion, champion spells, champions skins and champions info are locale independant
            if first_time:
                mastery_data = {
                    "id": mastery['id'],
                    "ranks": mastery['ranks'],
                    "image": mastery['image']['full'],
                    "tree": mastery['masteryTree']
                }
                newMastery = Masteries(**mastery_data)
                session.add(newMastery)

            translation_data = {
                "id_mastery": mastery['id'],
                "id_language": id_locale,
                "name": mastery['name'],
                "description": ','.join(mastery['sanitizedDescription'])
            }
            newTranslation = MasteriesTranslations(**translation_data)
            session.add(newTranslation)

        first_time = False
        print("todos los datos insertados con éxito para {}".format(locale))

    session.commit()
Esempio n. 3
0
    def get_summoner_info(self, summoner_name):
        """
        given a summoner name, retun the following data:

        {
            "profileIconId": 1665,
            "name": "EspinoKiller",
            "summonerLevel": 30,
            "accountId": 228772786,
            "id": 89028317,
            "revisionDate": 1500131820000
        }
        :param summoner_name: the summoner name of a player
        :return a dictionary with the info
        """
        summoner_info = get_response(
            BASE_URL.format(self.platform) +
            'summoner/v3/summoners/by-name/%s' % summoner_name)
        data = {
            'id':
            summoner_info['id'],
            'accountId':
            summoner_info['accountId'],
            'name':
            summoner_info['name'],
            'lvl':
            summoner_info['summonerLevel'],
            'icon':
            PROFILE_ICONS_URL.format(
                Configuration.get_version("champion version"),
                summoner_info['profileIconId'])
        }

        return data
Esempio n. 4
0
def add_detail():
    detail = request.form.get('detail')
    config = Configuration.objects().get(name='basic')
    details = config.details
    details.append(detail)
    config.details = details
    config.save()
    return Response(config.to_json(), mimetype="application/json", status=200)
Esempio n. 5
0
def add_header():
    header = request.form.get('header')
    config = Configuration.objects().get(name='basic')
    headers = config.headers
    headers.append(header)
    config.headers = headers
    config.save()
    return Response(config.to_json(), mimetype="application/json", status=200)
Esempio n. 6
0
 def post(self):
     try:
         user_id = get_jwt_identity()
         body = request.get_json()
         user = User.objects.get(id=user_id)
         configuration = Configuration(**body, added_by=user)
         configuration.save()
         user.update(push__configurations=configuration)
         user.save()
         id = configuration.id
         return {'id': str(id)}, 200
     except (FieldDoesNotExist, ValidationError):
         raise SchemaValidationError
     except NotUniqueError:
         raise ConfigurationAlreadyExistsError
     except Exception as e:
         raise InternalServerError
Esempio n. 7
0
def main():
    """
    for each locale json file reads the file parsing it to json and insert the data into the database
    :return: None
    """
    first_time = True
    for id_locale, locale in LOCALES.items():
        with open("{}.json".format(locale)) as inputfile:
            response = json.load(inputfile)

        try:
            version = session.query(Configuration).filter_by(code="{} version".format(response['type'])).one()
        except:
            configdata = {
                "code": "{} version".format(response['type']),
                "value": response['version']
            }
            print("añadiendo versión campeones")
            version = Configuration(**configdata)
            session.add(version)
        if version.value != response['version']:
            print("actualizando versión campeones")
            version.value = response['version']
            session.add(version)

        champions_data = response['data']

        for champion in champions_data.values():
            #champion, champion spells, champions skins and champions info are locale independant
            if first_time:
                get_champion(champion)
                get_champion_spells(champion, id_locale)
                get_champion_skins(champion, id_locale)
                get_champion_info(champion)

            get_champion_title(champion, id_locale)
            get_passive_translations(champion, id_locale)
            get_spell_translations(champion, id_locale)
            get_skin_translation(champion, id_locale)
            get_champion_allytips(champion, id_locale)
            get_champion_enemytips(champion, id_locale)

        first_time = False
        print("todos los datos insertados con éxito para {}".format(locale))
    session.commit()
Esempio n. 8
0
def delete_detail():
    detail = request.form.get('detail')
    config = Configuration.objects().get(name='basic')
    details = config.details
    while detail in details:
        details.remove(detail)
    config.details = details
    config.save()
    return Response(config.to_json(), mimetype="application/json", status=200)
Esempio n. 9
0
def delete_header():
    header = request.form.get('header')
    config = Configuration.objects().get(name='basic')
    headers = config.headers
    while header in headers:
        headers.remove(header)
    config.headers = headers
    config.save()
    return Response(config.to_json(), mimetype="application/json", status=200)
Esempio n. 10
0
    def get(self):
        user_id = get_jwt_identity()

        configurations = Configuration.objects().filter(
            added_by=user_id).to_json()

        response = Response(configurations,
                            mimetype="application/json",
                            status=200)
        response.headers['Access-Control-Allow-Origin'] = '*'
        response.headers['Access-Control-Allow-Headers'] = '*'
        response.headers['Access-Control-Allow-Credentials'] = 'true'
        response.headers[
            'Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS, HEAD'
        response.headers['Access-Control-Max-Age'] = '1209600'
        return response
Esempio n. 11
0
    def __init__(self):
        config = Configuration.objects().get(name='basic')
        self.header = config.headers
        self.details_list = config.details
        self.weights_header = [
            'S. No.', 'S. N.', 'S. No.', 'Sr. No.', 'Description', 'duty',
            'rate', 'HSN'
        ]
        self.header_ = [
            'S. No.',
            'S. N.',
            'S. No.',
            'Sr. No.',
            'Product ID',
            'Item Code ',
            'Cust Mat Code',
            'Material Code',  ###List of header attribute
            'Material Description',
            'Part No',
            'ISBN-13',
            'Product Code',
            'SKU',
            'SKU\tSales Order/No/Pos/SeqHSN',  ## make nw additions
            'HSN Code',
            'HSN/SAC',
            'HSN of Goods/ Services',
            'Title',
            'Item Description',
            'Description of Goods',
            'Desc of Goods/Services',
            'Title & Author',
            'Quantity',
            'Quantity',
            'QTY\tNo of packages',
            'SUPPL Qty',
            'Unit Price',
            'Mrp per Unit',
            'Basic Rate',
            'Unit Price\t',
            'Excise Duty',
            'Freight'
            'Discount Percentage',
            'Disc.',
            'Disc. (INR)',
            'Cash Discount (CD / amount * 100)SGST Percentage',
            'SGST/ UTGST',
            'Tax %',
            'Tax Rate',
            'CGST Percentage',
            'CGST Tax %',
            'IGST Percentage',
            'IGST Tax %',
            'Cess Percentage',
            'Discount3',
            'Discount2',
            'Discount1'
        ]
        #  'TCS Percentage', 'Total tax/Total amount * 100', 'Grand Total - Basic Total', 'Total Amount',
        # 'Net Payable','Ord.' 'Total (R/O)', 'Grand Total\t', 'APP%', 'Line Total', 'Total quantity pcs'
        # ]
        self.details_list_ = [
            'Seller State', 'Separate Country from State', 'State',
            'State Name', 'Place of Supply,', 'State Name & CodeSeller ID',
            'CIN No', 'PAN No', 'Seller Name', 'Header Parsing\t',
            'Registered Office Name & Address', 'Regd Office', 'Vendor Name',
            'Billed By', 'Seller Address', 'Vendor Address',
            'Seller GSTN Number', 'GSTN No\t,GSTIN/UIN', 'GSTIN  No.',
            'GST No', 'CIN', 'Vendor GSTIN', 'GST Inv No', 'Our GSTIN',
            'Country of Orgin', 'Along with State:', 'Currency',
            'Invoicing Currency', 'Description', 'Sale Order No',
            "Supplier's Ref", 'Payment Terms', 'Invoice Number', 'Invoice No',
            'Invoice No/Date', 'Invoice No/Series', 'Invoice Date',
            'Invoice Date', 'Date', 'Due Date', 'Due', 'Due Date',
            'DatePayment Due Date', 'Payable On', 'Payable On or before',
            'PO Number', 'Purchase Order No', 'Customer PO No', 'PO Details',
            'Supplier Ref', 'Invoice Items Total Amount', 'Buyer GSTN Number',
            'Contextual Analysis', 'GSTN No\t', 'GSTIN', 'GST Reg No',
            'GSTIN/Unique ID', 'GSTIN ID', 'Ship to Address\t',
            'Ship To\tPlace of Supply\tDelivery Address', 'ship to',
            'Sold to ', 'Name & Address', 'Name of Customer (Billed to)',
            'Buyer', 'Detail of Receiver', 'Consignee Name', 'Bill to Address',
            'Ship To', 'Name of Customer', 'Customer Name', 'delivery terms',
            'invoice time', 'freight', 'delivery terms', 'state',
            'delivery date', 'bill', 'Customer'
        ]

        self.search_details = {
            'no': ['Invoice Number', 'Invoice no', 'Invoice No'],
            'date': ['Invoice Date', 'Invoice Dt', 'Dated', 'Date'],
            'Due': [
                'Due', 'Due Date', 'Mode/Terms Of\n\nPayment',
                'Payment Due\n\nDate', 'payment terms'
            ],
            'gst': [
                'GSTN', 'GSTN No.', 'GSTIN ID', 'GSTIN/Unique ID', 'GSTN',
                'GSTIN/UIN'
            ],
            'po': ['PO No.'],
            'ship': [
                'Delivery Address', 'Bill to Address', 'Ship to',
                'Customer name', 'Buyer', 'Ship', 'Buyers address',
                'Buyer\'s asdress', 'Address', 'Consignee', 'Billed Bygits '
            ]
        }

        self.remove_list = ['id', 'basic', 'total', 'tax', '']
        # self.split_header()
        # print(self.header)
        # sys.exit()
        self.bbox = None
        self.header = [self.clean(head) for head in self.header]
        self.row_string = None
        self.similarity_index = None
        self.header_idx = None
        self.sheet = None
        self.info = None
        self.details = dict()
        self.details_status = []
        self.currency = 'INR'
        self.rows = None
        self.cols = None
        self.outside = None
Esempio n. 12
0
def update_num_of_threads(thread):
    config = Configuration.objects().get(name='basic')
    config.num_of_threads = thread
    config.save()
    return Response(config.to_json(), mimetype="application/json", status=200)
Esempio n. 13
0
def get_basic_config():
    config = Configuration.objects().get(name='basic').to_json()
    return Response(config, mimetype="application/json", status=200)