From f3b47e0f5b9d6e50ef5529f115cd87b374188785 Mon Sep 17 00:00:00 2001 From: simplePCBuilding <98422316+simplePCBuilding@users.noreply.github.com> Date: Sat, 26 Feb 2022 11:02:03 +0100 Subject: [PATCH] Initial Commit --- .idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/test scrapping.iml | 10 +++ bin/config/case.py | 0 bin/config/cooler.py | 0 bin/config/cpu.py | 0 bin/config/gpu.py | 0 bin/config/hdd.py | 0 bin/config/mbd.py | 0 bin/config/os.py | 0 bin/config/psu.py | 0 bin/config/ssd.py | 0 bin/config/userprofile_creator.py | 34 +++++++ bin/lib/csv_parsers.py | 65 ++++++++++++++ bin/modules/configurator.py | 18 ++++ bin/modules/updater.py | 0 .../backend/componentmanager.py | 36 ++++++++ .../backend/package_managing.py | 55 ++++++++++++ bin/package_manager/gui/gui.kv | 57 ++++++++++++ .../price_extractor_objectoriented.py | 90 +++++++++++++++++++ bin/price_extractor/price_scrapper_v2.py | 45 ++++++++++ data/prices.csv | 5 ++ data/prices/cpu_p.csv | 2 + data/product_info/coolers.csv | 3 + data/product_info/cpu.csv | 3 + data/product_info/gpu.csv | 0 data/product_info/mbd.csv | 3 + data/product_info/psu.csv | 0 data/products.csv | 4 + ...plePCBuilding-Structure-Component-List.txt | 13 +++ old/price_extractor.py | 45 ++++++++++ simplePCBuilding-PC-Configurator-alpha1.py | 69 ++++++++++++++ test.py | 34 +++++++ 35 files changed, 612 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/test scrapping.iml create mode 100644 bin/config/case.py create mode 100644 bin/config/cooler.py create mode 100644 bin/config/cpu.py create mode 100644 bin/config/gpu.py create mode 100644 bin/config/hdd.py create mode 100644 bin/config/mbd.py create mode 100644 bin/config/os.py create mode 100644 bin/config/psu.py create mode 100644 bin/config/ssd.py create mode 100644 bin/config/userprofile_creator.py create mode 100644 bin/lib/csv_parsers.py create mode 100644 bin/modules/configurator.py create mode 100644 bin/modules/updater.py create mode 100644 bin/package_manager/backend/componentmanager.py create mode 100644 bin/package_manager/backend/package_managing.py create mode 100644 bin/package_manager/gui/gui.kv create mode 100644 bin/price_extractor/price_extractor_objectoriented.py create mode 100644 bin/price_extractor/price_scrapper_v2.py create mode 100644 data/prices.csv create mode 100644 data/prices/cpu_p.csv create mode 100644 data/product_info/coolers.csv create mode 100644 data/product_info/cpu.csv create mode 100644 data/product_info/gpu.csv create mode 100644 data/product_info/mbd.csv create mode 100644 data/product_info/psu.csv create mode 100644 data/products.csv create mode 100644 docs/simplePCBuilding-Structure-Component-List.txt create mode 100644 old/price_extractor.py create mode 100644 simplePCBuilding-PC-Configurator-alpha1.py create mode 100644 test.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..460ceda --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/test scrapping.iml b/.idea/test scrapping.iml new file mode 100644 index 0000000..0e4e9fa --- /dev/null +++ b/.idea/test scrapping.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bin/config/case.py b/bin/config/case.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/cooler.py b/bin/config/cooler.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/cpu.py b/bin/config/cpu.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/gpu.py b/bin/config/gpu.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/hdd.py b/bin/config/hdd.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/mbd.py b/bin/config/mbd.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/os.py b/bin/config/os.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/psu.py b/bin/config/psu.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/ssd.py b/bin/config/ssd.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/config/userprofile_creator.py b/bin/config/userprofile_creator.py new file mode 100644 index 0000000..6e90bf9 --- /dev/null +++ b/bin/config/userprofile_creator.py @@ -0,0 +1,34 @@ +"""@package docstring +This module asks the user questions so the software can configure the PC. +""" + + +class UserprofileCreator: + def __init__(self): + print("""First of all we need your name so we can match it with you.""") + self.i = 0 + + def chg_username(self): + self.i = input("please enter your name") + return self.i + + def chg_budget(self): + self.i = input("Now, how big is your budget? ") + return self.i + + def chg_use_case(self): + """""" + print("""Now we need some information regarding your intended use-case for this system. + o = Office-PC (you are editing documents, creating pdfs, browsing the web + c = Content Creation PC (you are editing videos, editing photos or other similarly intense workloads + g = Gaming-PC (You are playing games, maybe streaming as well?) + """) + self.i = input("Choose your use-case from above") + return self.i + + def chg_os(self): + print("""simplePCBuilding offers the installation of different Operating Systems. You can choose from + following: + W10 = Windows 10 + W11 = Windows 11 + L = any Linux-Distro""") diff --git a/bin/lib/csv_parsers.py b/bin/lib/csv_parsers.py new file mode 100644 index 0000000..1693d08 --- /dev/null +++ b/bin/lib/csv_parsers.py @@ -0,0 +1,65 @@ +"""@package docstring +This is a simplification of the csv module""" + +import csv + + +class CsvRead: + """This is a class that reads csv files and depending on the module selected does do different things with it""" + def __init__(self): + self.__imp = "" + self.__raw = "" + self.__raw_list = "" + + def importing(self, path): + """Returns a list of the imported csv-file, requires path, either direct system path or relative path""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__raw_list = list(self.__raw) + return self.__raw_list + + +class CsvWrite: + """This is a class that modifies csv files""" + def __init__(self): + self.__impl = [] + self.__strpop = [] + self.__removed = [] + self.__removing = 0 + self.__change = 0 + self.__appending = 0 + + def rem_str(self, path, row): + """Opens the csv-file in write mode which is specified as an argument either as direct or relative path""" + self.__impl = CsvRead.importing(path) + self.__removed = self.__impl.pop(row) + with open(path, "w") as removedata: + self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__removed) + + def chg_str(self, path, row, pos, new_value): + """Opens the csv-file in write mode to change a value, e.g. if a recipes is changed.""" + self.__impl = CsvRead.importing(path) + self.__strpop = self.__impl.pop(row) + self.__strpop.remove(pos) + self.__strpop.insert(pos, new_value) + self.__impl.insert(row, self.__strpop) + with open(path, "w") as changedata: + self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__change.writerow(self.__impl) + + def app_str(self, path, value): + """Opens the csv-file in append mode and writes given input. CsvWrite.app_str(path, value). + Path can be specified both as direct or relative. value is a list. Will return an error if type of value is + not a list.""" + with open(path, "a") as appenddata: + self.__appending = csv.writer(appenddata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__appending.writerow(value) + + def initialize(self): + with open("../../data/ingredients/ingredients.csv", "w") as initializedata: + self.__creating = csv.writer(initializedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__creating.writerow(["Setup-Success"]) + with open("../../data/recipes/recipes.csv", "w") as initializedata: + self.__creating = csv.writer(initializedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__creating.writerow(["Setup-Success"]) diff --git a/bin/modules/configurator.py b/bin/modules/configurator.py new file mode 100644 index 0000000..6d0d05b --- /dev/null +++ b/bin/modules/configurator.py @@ -0,0 +1,18 @@ +"""@package docstring +This module configures PCs but relies heavily on external modules that are included with the package. +""" + + +class ConfigCreator: + def __init__(self): + print(""" + + + +Welcome to the PC-Configurator! +-------------------------------- + +We still need a couple of informations so we can make sure you get the best configuration possible! + +No more questions? Let's start! +""") diff --git a/bin/modules/updater.py b/bin/modules/updater.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/package_manager/backend/componentmanager.py b/bin/package_manager/backend/componentmanager.py new file mode 100644 index 0000000..83de3e0 --- /dev/null +++ b/bin/package_manager/backend/componentmanager.py @@ -0,0 +1,36 @@ +from kivy.app import App +from kivy.lang import Builder +from kivy.uix.screenmanager import Screen, ScreenManager +from kivy.uix.popup import Popup + + +class MainScreen(Screen): + pass + + +class AddComponent(Screen): + pass + + +class ModifyComponent(Screen): + pass + + +class RemoveComponent(Screen): + pass + + +class RootScreen(ScreenManager): + pass + + +kv = Builder.load_file("../gui/gui.kv") + + +class ComponentManager(App): + def build(self): + return kv + + +if __name__ == "__main__": + ComponentManager().run() diff --git a/bin/package_manager/backend/package_managing.py b/bin/package_manager/backend/package_managing.py new file mode 100644 index 0000000..c230745 --- /dev/null +++ b/bin/package_manager/backend/package_managing.py @@ -0,0 +1,55 @@ +import datetime +import csv +"""@package docstring +This software / package is used to easily manage the available products. This software will automatically update +whenever there is an update for the reader available on the website. +-------- + +NOTE: This software changes files in the directory in which it is located and as such is not made for +inexperienced users. Please read the readme.txt file for further notice. + +NOTE: This software does not feature a standard gui (Graphical User Interface) currently and as such is +based on commands. You cna find a full lists of commands on the wiki. + +NOTE: The simplePCBuilding-Configurator comes with an Update service for the component list. In the event of +an Update, there is a script installed with your software that merges the new updates to the components file +with the changes you made. + +NOTE: Changing the CSV-File containing the component information with any other editor other than this one, +the file might get unreadable for the software. Do always use this software here to change something. +""" +version = str("alpha 1.0") +print(""" +================================================================ +Welcome to the simplePCBuilding PC-Configurator-Package-Manager! +You are currently running""", version, """! +================================================================ + +This software is used to easily manage the available products. This software will automatically update +whenever there is an update for the reader available on the website. +-------- + +NOTE: This software changes files in the directory in which it is located and as such is not made for +inexperienced users. Please read the readme.txt file for further notice. + +NOTE: This software does not feature a standard gui (Graphical User Interface) currently and as such is +based on commands. You cna find a full lists of commands on the wiki. + +NOTE: The simplePCBuilding-Configurator comes with an Update service for the component list. In the event of +an Update, there is a script installed with your software that merges the new updates to the components file +with the changes you made. + +NOTE: Changing the CSV-File containing the component information with any other editor other than this one, +might result in loss of correct operation of the software. Do always use this software here to change something. +""") + + + +i = input("Please read above carefully and type a y to continue, a \"n\" to exit the software:") + +if i == "y": + print("Starting...") + +else: + print("Leaving...") + diff --git a/bin/package_manager/gui/gui.kv b/bin/package_manager/gui/gui.kv new file mode 100644 index 0000000..d628d67 --- /dev/null +++ b/bin/package_manager/gui/gui.kv @@ -0,0 +1,57 @@ +RootScreen: + MainScreen: + AddComponent: + RemoveComponent: + ModifyComponent: + +: + name: "Main" + GridLayout: + cols:1 + Label: + text: "Welcome to the simplePCBuilding\n PC-Configuration-Suite\n Component-Manager!" + font_size:30 + color: (0,0,1,0.6) + FloatLayout: + GridLayout: + size_hint: 0.9, 0.9 + pos_hint:{"x":0.05, "y":0.05} + cols:3 + Button: + text: "New Component" + on_release: + app.root.current = "NewComp" + root.manager.transition.direction = "right" + Button: + text: "Modify Component" + on_release: + app.root.current = "ModComp" + root.manager.transition.direction = "down" + Button: + text: "Remove Component" + on_release: + app.root.current = "RemComp" + root.manager.transition.direction = "left" + +: + name: "NewComp" + GridLayout: + cols:1 + Label: + text: "New Component" + +: + name: "ModComp" + GridLayout: + cols:1 + Label: + text: "Modify Component" + + +: + name: "RemComp" + GridLayout: + cols:1 + Label: + text: "Remove Component" + diff --git a/bin/price_extractor/price_extractor_objectoriented.py b/bin/price_extractor/price_extractor_objectoriented.py new file mode 100644 index 0000000..1bf468b --- /dev/null +++ b/bin/price_extractor/price_extractor_objectoriented.py @@ -0,0 +1,90 @@ +"""@package docstring +This package extracts prices from websites. Currently, the package only allows for extraction of prices from +https://digitec.ch/""" + +import requests +import csv +import datetime + + +class PriceExtractor: + def __init__(self): + with open("../../data/prices.csv", "w") as pricedata: + self.__writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__writing.writerow(["version from", datetime.datetime.now()]) + self.__imp = open("../../data/products.csv", "r") + self.__raw_imp = csv.reader(self.__imp, delimiter=',') + self.__raw_list = list(self.__raw_imp) + self.__productcount = len(self.__raw_list) + print("needing to update", self.__productcount, "prices") + self.__productnumber = 0 + self.__website = "" + self.__ingest = "" + self.__res = "" + self.__priceIdx = 0 + self.__check = 0 + self.__request_done = "" + self.__raw_price = "" + self.__price = 0 + self.__price_extract = 0 + + def readfile(self, filename): + """Reads a new file that contains links in csv format. Arguments: + Filename. Either specify full path (e.g. /home/[username]/price_extractor/prices.csv), relative path when + inside the folder of the executable (e.g. /pricedata/prices2.csv) or inside another folder that is located in + the parent folder (e.g. ../pricedata/prices3.csv). + Returns the content of the file inside of a list. + + Example: prices = PriceExtractor.readfile(/pricedata/prices2.csv) (NOTE: prices is a list in this case!)""" + with open(filename, "w") as pricedata: + self.__writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__writing.writerow(["version from", datetime.datetime.now()]) + self.__imp = open("../../data/products.csv", "r") + self.__raw_imp = csv.reader(self.__imp, delimiter=',') + self.__raw_list = list(self.__raw_imp) + self.__productcount = len(self.__raw_list) + print("needing to update", self.__productcount, "prices") + self.__productnumber = 0 + return self.__raw_list + + def chg_website(self, website): + """Change the website (exact URL to product on https://digitec.ch/ only currently). Arguments: + Website. Only put direct link to product on digitec. Will return an error if a link other than digitec is + specified, though might work if the website structure is similar. + + Example: PriceExtractor.chg_website(https://www.digitec.ch/de/s1/product/asus-radeon-rx-6600-dual-8-gb-grafikkarte-16833213)""" + self.__website = website + + def digitec_extractor(self): + """Run through the entire list of links specified in the csv file that was selected either when loading the + function or when specified through the method \"readfile\". NOTE: This method does not require any additional + arguments and also does run through the entire file!""" + while self.__productnumber < self.__productcount: + self.__ingest = self.__raw_list.pop(0) + self.__website = self.__ingest.pop(1) + self.__productnumber = int(self.__ingest.pop(0)) + print("fetching data... This step might take a couple of seconds") + self.__res = requests.get(self.__website) + print("recieved data from", self.__website) + self.__check = str(self.__res) + if self.__check == "": + print("Ressource unavailable, skipping..") + else: + self.__request_done = self.__res.text + self.__priceIdx = self.__request_done.index('property="product:price:amount') + self.__raw_price = self.__request_done[self.__priceIdx + 41:self.__priceIdx + 60] + self.__price_extract = "" + for buchstabe in self.__raw_price: + if buchstabe == "\"": + break + else: + self.__price_extract += buchstabe + self.__price = float(self.__price_extract) + print("The price is following: ", self.__price, "CHF\n") + with open("../../data/prices.csv", "a") as pricedata: + writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + writing.writerow([self.__productnumber, self.__price]) + + +digitec_ext = PriceExtractor() +digitec_ext.digitec_extractor() diff --git a/bin/price_extractor/price_scrapper_v2.py b/bin/price_extractor/price_scrapper_v2.py new file mode 100644 index 0000000..52db1dd --- /dev/null +++ b/bin/price_extractor/price_scrapper_v2.py @@ -0,0 +1,45 @@ +import bin.lib.csv_parsers +import requests +import datetime + +cvr = bin.lib.csv_parsers.CsvRead() +cvw = bin.lib.csv_parsers.CsvWrite() + +class PriceExtractor: + def __init__(self): + + def update_all_prices(self, folder): + self.digitec_extractor() + + + def digitec_extractor(self): + """Run through the entire list of links specified in the csv file that was selected either when loading the + function or when specified through the method \"readfile\". NOTE: This method does not require any additional + arguments and also does run through the entire file!""" + while + + while self.__productnumber < self.__productcount: + self.__ingest = self.__raw_list.pop(0) + self.__website = self.__ingest.pop(1) + self.__productnumber = int(self.__ingest.pop(0)) + print("fetching data... This step might take a couple of seconds") + self.__res = requests.get(self.__website) + print("recieved data from", self.__website) + self.__check = str(self.__res) + if self.__check == "": + print("Ressource unavailable, skipping..") + else: + self.__request_done = self.__res.text + self.__priceIdx = self.__request_done.index('property="product:price:amount') + self.__raw_price = self.__request_done[self.__priceIdx + 41:self.__priceIdx + 60] + self.__price_extract = "" + for buchstabe in self.__raw_price: + if buchstabe == "\"": + break + else: + self.__price_extract += buchstabe + self.__price = float(self.__price_extract) + print("The price is following: ", self.__price, "CHF\n") + with open("../../data/prices.csv", "a") as pricedata: + writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + writing.writerow([self.__productnumber, self.__price]) diff --git a/data/prices.csv b/data/prices.csv new file mode 100644 index 0000000..846c1a0 --- /dev/null +++ b/data/prices.csv @@ -0,0 +1,5 @@ +version from,2022-02-17 09:30:53.233664 +1,559.0 +2,290.0 +3,9.2 +4,359.0 diff --git a/data/prices/cpu_p.csv b/data/prices/cpu_p.csv new file mode 100644 index 0000000..45a5fdd --- /dev/null +++ b/data/prices/cpu_p.csv @@ -0,0 +1,2 @@ +simplePCBuilding-CPU-Price-Library +ID, DIGITEC-Price, \ No newline at end of file diff --git a/data/product_info/coolers.csv b/data/product_info/coolers.csv new file mode 100644 index 0000000..307fb07 --- /dev/null +++ b/data/product_info/coolers.csv @@ -0,0 +1,3 @@ +simplePCBuilding-Cooler-Listing +ID,MANUFACTURER,COOLERTYPE,NAME,Mounting_Kit,MAXTDP,Height,WidthX,WidthY,FAN_SIZE,FAN_COUNT, +1,Noctua,Air-Tower,NH-U12S Redux,,120,,,,120,1, \ No newline at end of file diff --git a/data/product_info/cpu.csv b/data/product_info/cpu.csv new file mode 100644 index 0000000..ff1ee9d --- /dev/null +++ b/data/product_info/cpu.csv @@ -0,0 +1,3 @@ +simplePCBuilding-CPU-data-Library +ID,DIGITEC-LINK,MANUFACTURER,SOCKET,ARCHITECTURE,SERIES,EARLIEST_COMPATIBLE_CHIPSET,TDP,FULL_NAME +1,,AMD,AM4,Zen3,Ryzen 5000,B450,65,AMD Ryzen 5 5600X \ No newline at end of file diff --git a/data/product_info/gpu.csv b/data/product_info/gpu.csv new file mode 100644 index 0000000..e69de29 diff --git a/data/product_info/mbd.csv b/data/product_info/mbd.csv new file mode 100644 index 0000000..911bacf --- /dev/null +++ b/data/product_info/mbd.csv @@ -0,0 +1,3 @@ +simplePCBuilding-Motherboard-data-Library +ID,SOCKET,CHIPSET,SIZE,RAM_SUPPORT,MaxRAMCapacity,PCIeSLOTS(x16),NVMeSLOTS,FAN_HEADERS,ARGB_HEADERS,RGB12V_Headers,WiFi,S-ATA-CONNECTORS,F_USB_3.x,F_USB_2.x,F_USB_C,EPS12V_Pins +1,AM4,Z590,ATX,DDR4-3200,128,2,2,4,2,2,y,6,2,3,0,12 \ No newline at end of file diff --git a/data/product_info/psu.csv b/data/product_info/psu.csv new file mode 100644 index 0000000..e69de29 diff --git a/data/products.csv b/data/products.csv new file mode 100644 index 0000000..d4b1d2e --- /dev/null +++ b/data/products.csv @@ -0,0 +1,4 @@ +1,https://www.digitec.ch/de/s1/product/asus-radeon-rx-6600-dual-8-gb-grafikkarte-16833213 +2,https://www.digitec.ch/de/s1/product/amd-ryzen-5-5600x-am4-370-ghz-6-core-prozessor-13987919 +3,https://www.digitec.ch/de/s1/product/thermal-grizzly-kryonaut-1250-wm-k-1-g-waermeleitmittel-5614395 +4,https://www.digitec.ch/de/s1/product/apple-ipad-2021-9-gen-1020-64-gb-space-grey-tablet-16644686 diff --git a/docs/simplePCBuilding-Structure-Component-List.txt b/docs/simplePCBuilding-Structure-Component-List.txt new file mode 100644 index 0000000..65d0628 --- /dev/null +++ b/docs/simplePCBuilding-Structure-Component-List.txt @@ -0,0 +1,13 @@ +-------------- +MOTHERBOARDS +-------------- +Require following: + SOCKET: (Such as AM4, AM5, LGA 1200, LGA 1700) + CHIPSET: (Such as AMD-B550, AMD-X570, Intel-Z690) + SIZE: (Such as ATX, E-ATX, mATX) + RAM_SUPPORT: (Such as DDR4-3200) + PCIeSLOTS: (e.g. 2x16 1x8 1x4, 1x16 1x8) + NVMeSLOTS: (e.g. 2xM-Key 1xB+M-Key, 2xM-Key) + FAN_HEADERS: (e.g. 2) + ARGB_HEADERS + F_CONNECTORS: (LIST!!!) diff --git a/old/price_extractor.py b/old/price_extractor.py new file mode 100644 index 0000000..f1560af --- /dev/null +++ b/old/price_extractor.py @@ -0,0 +1,45 @@ +#IMPORTS +import requests +import csv +import datetime + +with open("prices.csv", "w") as pricedata: + writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + writing.writerow(["version from", datetime.datetime.now()]) + +#reading of Product-CSV-File; Variable definition +imp = open("products.csv","r") +raw_imp = csv.reader(imp, delimiter=',') +raw_list = list(raw_imp) +productcount = len(raw_list) +print("needing to update",productcount, "prices") +productnumber = 0 + +#DATA-RECIEVING +while productnumber < productcount: + ingest = raw_list.pop(0) + website = ingest.pop(1) + productnumber = int(ingest.pop(0)) + print("fetching data... This step might take a couple of seconds") + res = requests.get(website) + print("recieved data from", website) + check = str(res) + if check == "": + print("Ressource unavailable, skipping..") + + else: + request_done = res.text + priceIdx = request_done.index('property="product:price:amount') + raw_price = request_done[priceIdx+41:priceIdx+60] + price_extract = "" + for buchstabe in raw_price: + if buchstabe == "\"": + break + else: + price_extract += buchstabe + + price = float(price_extract) + print("The price is following: ", price, "CHF\n") + with open("prices.csv", "a") as pricedata: + writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + writing.writerow([productnumber, price]) \ No newline at end of file diff --git a/simplePCBuilding-PC-Configurator-alpha1.py b/simplePCBuilding-PC-Configurator-alpha1.py new file mode 100644 index 0000000..9a04954 --- /dev/null +++ b/simplePCBuilding-PC-Configurator-alpha1.py @@ -0,0 +1,69 @@ +# This is the main runtime of the simplePCBuilding-PC-Configurator +# IMPORTS +import time + + +version = "alpha 1.0" +print(""" +-------------------------------------------------------------------- + WELCOME TO THE simplePCBuilding PC CONFIGURATOR + YOU ARE CURRENTLY RUNNING VERSION""", version, """ +---------------------------------------------------------------------""") +time.sleep(1) +print(""" + +Please note that this software is developed and distributed by simplePCBuilding +and as such you are not allowed to sell and / or distribute this software on +your own. If you want to share this project with others, please refer to our +guidelines and do only provide the official download-link. + +""") +time.sleep(1) +print("""This software is split up into different modules you can use. +Select the appropriate one: +MODULE LIST: +- Configurator (c) +- Updater (u) +- Package manager (p) +- Quit (q) + +To select a module, please type the correct letter (found in brackets behind +the module name in the above list) in through your keyboard +""") +i = input("please choose the module you want to use: ") +go = 1 + +while go == 1: + if i == "c": + print("starting configurator...") + go = 0 + + elif i == "u": + print("starting updater...") + go = 0 + + elif i == "p": + print("starting package manager...") + go = 0 + + elif i == "q": + print("killing processes....") + time.sleep(0.5) + print("Terminating...") + go = 0 + + else: + print("\nUnknown entry, please retry.\n ") + time.sleep(0.5) + print("""This software is split up into different modules you can use. +Select the appropriate one: + MODULE LIST: + - Configurator (c) + - Updater (u) + - Package manager (p) + - Quit (q) + + To select a module, please type the correct letter (found in brackets behind + the module name in the above list) in through your keyboard + """) + i = input("Please select a module and type in the corresponding letter: ") diff --git a/test.py b/test.py new file mode 100644 index 0000000..52b33fa --- /dev/null +++ b/test.py @@ -0,0 +1,34 @@ +class Human(): + def __init__(self, price, name="n/a"): + print("human created") + self.age = 0 + self.numberOfLegs = 2 + self.name = name + + def setName(self, name): + self.name = name + + def getName(self): + return self.name + + def __str__(self): + ret = " " + ret += "\n Name: " + ret += self.name + ret += "\n Age:" + ret += str(self.age) + return ret + +class Lumberjack(Human): + def __init__(self): + print("Lumberjack created") + #ruft den Konstruktor der Oberklasse auf + Human.__init__(self, 300) + + +myL = Lumberjack() + +print(myL.name) + + +#doxygen --> For documentation \ No newline at end of file