Package: kor-project
The Kor ProjectAn easy-to-use module to store data in filesPresentationProject goalsBeing able to store small amount data in a new wayBeing easy to useBeing intuitiveBeing expendableWhy use kor ?The kor module allows for easy file manipulation with great expandabilityYou can create you own encoding method and share them to whoever you wantEasy to understand line-by-line conceptLine-by-line ? Tell me more !When working with kor (and .kor files) your data will be stored as a line, for instance, if I would like to encode"My_String"the result in the file will bevar : name -> str -> My_Stringfollowing this pattern :line_type : line_name -> value_type -> valueRemember that the first line starts at 0 and not one ! The first two lines (0 & 1) are usually used to store information such as the author and the description of the file !InstallationWith pip :pip install kor-projectRun this command in your CMDIf you don't havepipinstalled check out this website by MakeUsOfhttps://www.makeuseof.com/tag/install-pip-for-python/Quick exempleYour project directory should look like this templateproject_dir
    |
    |_ <your_file>.py
    |_ <your_file>.korIf you decide to put the .kor file in another directory/subdir you will have to give the full pathOpening your fileimportkormy_file=kor.Kor(file_path="./<your_file>.kor")Writing commentsimportkormy_file=kor.Kor(file_path="./<your_file>.kor")my_file.encode_comment(line=4,value="This is a comment")First line type :varThe 'var' type is probably the one I (and maybe you) use the most, it is the short forvariableand can store numbers, bool and stringimportkormy_file=kor.Kor(file_path="./<your_file>.kor")# To make you first var you'll need to create a instance of the Var classmy_var=kor.Var(name="Var_Name",value="Var_Value",value_type="str")#possible value type : 'num', 'str' & 'bool'#The add it to you filemy_var.encode(line=5,file=my_file,override=False)# See the documentation for more infoReading the fileimportkormy_file=kor.Kor(file_path="./<your_file>.kor")***Dosomestuffwiththefile...***#Decode every lines of your filemy_file.decode()##DocumentationClassesclasskor.Kor(file_path)Represent your file in the codeParameterfile_path: The path to you fileclasskor.Var(name, value, value_type)Represent you Var-type lines in the codeParametersname: The name of the linevalue: The content of the linevalue_type: Type of the value(num, str or bool)classkor.List(name, value, value_type)Represent you List-type lines in the codeParametersname: The name of the linevalue: The content of the linevalue_type: Type of the value(num, str or bool)classkor.CustomLines(name, value, custom_encoding, custom_value_type, custom_separator, custom_line_type)Represent you custom line typesParametersname: The name of the linevalue: The content of the linecustom_encoding: Your custom encoding function for this custom line typecustom_value_type: Your custom value_type for this custom line typecustom_separator: Your custom separator for this custom line type(e.g :custom : name -> custom -> value<separator>value2)custom_line_type: Your custom line type name for this custom line typekor.Kor()methodskor.Kor.add_author(author)Allows you to set an author for you fileParameterauthor: The author of the filekor.Kor.add_desc(desc)Allows you to add a description to your fileParameterdesc: The description of your filekor.Kor.get_author()Returnsauthorstr: The author of the filekor.Kor.get_desc()Returnsdescstr: The description of the filekor.Kor.encode_comment(line, value)Allows you to add comments to your fileParametersline: Line where your comment should be encodedvalue: Content of your commentkor.Kor.decode(custom_line_type:list=None, custom_decoding:list=None, custom_separator:list=None)Used to decode your entire fileParametersOnly use when using custom line type (kor.CustomLines)custom_line_type:list: A list of all your custom line typecustom_decoding:list: A list of all your custom decoding functionscustom_separator:list: A list of all your custom separatorskor.Kor.write(content:list)Allows you to write content directly to the file (it does not process lines to encode them properly !)Parametercontent:list: A list of all the lines to write to the filekor.Kor.read()ReturnsThe no-decoded lines, mainly used to see what inside the file without decodingkor.Kor.delete(line, replace_blank = True)Delete a line of the fileParametersline: The line to deletereplace_blank:bool:True= replace with a blank line (\n),False= Does not replacekor.Kor.reset()Resets you file(erase all data stored in it including information such as author and description)kor.Var()&kor.List()methodskor.Var.&kor.List.encode(line, file, override=False)Used to encode your line to a specific fileParametersline: The line in the file where it should be encodedfile: The file where you line should be encodedoverride:bool=True:True= If there is already a line existing at this line number, it deletes it and replace with the new one,False= It does notkor.CustomLines()methodkor.CustomLines.encode(line, file, override=False)Used to encode your custom line typeParametersline: The line in the file where it should be encodedfile: The file where you line should be encodedoverride:bool=True:True= If there is already a line existing at this line number, it deletes it and replace with the new one,False= It does not`More ExemplesCustom encoding and decoding(in a few easy steps !)Step 1Assuming you have already imported kor and created your instance of the Kor class...Create variables to store your custom assetsc_line_type=[]c_value_type=[]c_separators=[]c_decoding=[]Step 2Create function to encode and decode your object...We're encodingobjin this example but this apply to every object)classobj:def__init__(self,name,age):self.name=nameself.age=agedef__repr__(self):returnf"obj(name='{self.name}', age='{self.age}')"# Custom encoding an decoding fuctionsdefcustom_encode(line_type,name,value,value_type,separator):#Those parameters will be passed when you will encode your custom line typereturnf"{line_type}:{name}->{value_type}->{value.name}{separator}{value.age}"defcustom_decode(args):#This argument will be passed when you will decode your custom line typereturnobj(name=args[0],age=args[1])... and addcustom_decode()inc_decoding. Don't forget the other variables tooc_line_type.append("My_Custom_Line_Type")c_value_type.append("My_Custom_Value_Type")c_separators.append(";")c_decoding.append(custom_decode)Step 3You're done !Now try to encode and decode with your custom line types !my_custom_line=kor.CustomLines(name="My_line",value=obj(name="KoraKu",age="16"),custom_encoding=custom_encode,custom_line_type=c_line_type[0],custom_separator=c_separators[0],custom_value_type=c_value_type[0])my_custom_line.encode(line=10,file=my_file,override=True)my_file.decode(custom_line_type=c_line_type,custom_decoding=c_decoding,custom_separator=c_separators)LinksPyPi page :https://pypi.org/project/kor-project/