Skip to content

Commit

Permalink
Moving on #386 and #359 (class models)
Browse files Browse the repository at this point in the history
  • Loading branch information
hildogjr committed May 24, 2020
1 parent 9d47e14 commit 5163bfb
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
46 changes: 46 additions & 0 deletions kicost/edas/eda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# MIT license
#
# Copyright (C) 2020 by Hildo Guillardi Junior
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# Libraries.


from .global_vars import *


__all__ = ['eda_class']


class eda_class(object):
def __init__(self, name, logger):
self.name = name
self.logger = logger

def get_part_groups(in_file):
'''Get groups of identical parts from an generic CSV file and return them as a dictionary.
@param in_file `str()` with the file name.
@param ignore_fields `list()` fields do be ignored on the read action.
@param variant `str()` in regular expression to match with the design version of the BOM.
For now, `variant`is not used on CSV read, just kept to compatibility with the other EDA submodules.
@return `dict()` of the parts designed. The keys are the components references.
'''

#TODO this file aims to be a base class file for create all the BOM readers.
6 changes: 6 additions & 0 deletions kicost/edas/eda_altium.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
from .tools import field_name_translations, remove_dnp_parts
from .tools import PART_REF_REGEX_NOT_ALLOWED

from .eda import eda_class

class eda_altium(eda_class):
def __init__(self):
pass

# Add to deal with the fileds of Altium and WEB tools.
field_name_translations.update(
{
Expand Down
7 changes: 7 additions & 0 deletions kicost/edas/eda_kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
from .tools import field_name_translations, remove_dnp_parts


from .eda import eda_class

class eda_altium(eda_class):
def __init__(self):
pass


__all__ = ['get_part_groups']

from . import eda_dict
Expand Down
8 changes: 7 additions & 1 deletion kicost/edas/generic_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
from .tools import field_name_translations, remove_dnp_parts, split_refs
from ..distributors.global_vars import distributor_dict

from .eda import eda_class

class generic_csv(eda_class):
def __init__(self):
pass

# Add to deal with the generic CSV header purchase list.
field_name_translations.update(
{
Expand Down Expand Up @@ -93,7 +99,7 @@ def get_part_groups(in_file, ignore_fields, variant):
@param ignore_fields `list()` fields do be ignored on the read action.
@param variant `str()` in regular expression to match with the design version of the BOM.
For now, `variant`is not used on CSV read, just kept to compatibility with the other EDA submodules.
@return `dict()` of the parts designed. The keys are the componentes references.
@return `dict()` of the parts designed. The keys are the components references.
'''

ign_fields = [str(f.lower()) for f in ignore_fields]
Expand Down
25 changes: 25 additions & 0 deletions kicost/edas/global_vars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# MIT license
#
# Copyright (C) 2018 by XESS Corporation / Hildo Guillardi Junior
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# Heritage of the above global vars.
from ..global_vars import * # Debug information and `SEPRTR`.

0 comments on commit 5163bfb

Please sign in to comment.