Kaynağa Gözat

rename pika_configparser to configparser

pikastech 3 yıl önce
ebeveyn
işleme
d3a9f6e226

+ 0 - 112
package/pika_configparser/pika_configparser.py

@@ -1,112 +0,0 @@
-from PikaStdData import String
-
-class ConfigParser():
-    content = ''
-    config_dict = {}
-
-    def _parse(self):
-        self.content = String(self.content).replace('\r', '')
-        content = String(self.content)
-        lines = content.split('\n')
-        for line in lines:
-            line = String(line)
-            if line.startwith('#'):
-                continue
-            if line.startwith(';'):
-                continue
-            if line.startwith('['):
-                section = String(line.replace('[', ''))
-                section = section.replace(']', '')
-                self.config_dict[section] = {}
-                continue
-
-            if line.strip() == '':
-                continue
-
-            stmt = line.split('=')
-            key = String(stmt[0]).strip()
-            value = String(_getvalue(stmt)).strip()
-            section_dict = self.config_dict[section]
-            section_dict[key] = value
-
-    def sections(self):
-        section_keys = self.config_dict.keys()
-        sections = []
-        for section_item in section_keys:
-            sections.append(section_item)
-        return sections
-
-    def options(self, section):
-        section_dict = self.config_dict[section]
-        option_keys = section_dict.keys()
-        options = []
-        for option_item in option_keys:
-            options.append(option_item)
-        return options
-
-    def get(self, section, option):
-        section_dict = self.config_dict[section]
-        return section_dict[option]
-
-    def set(self, section, option, value):
-        section_dict = self.config_dict[section]
-        section_dict[option] = value
-
-    # support config[key] = val
-    def __set__(self, __key, __val):
-        self.config_dict[__key] = __val
-
-    # support val = config[key]
-    def __get__(self, __key):
-        return self.config_dict[__key]
-
-    def items(self, section):
-        section_dict = self.config_dict[section]
-        section_keys = section_dict.keys()
-        items = []
-        for key in section_keys:
-            val = section_dict[key]
-            items.append([key, val])
-        return items
-
-    def __str__(self):
-        content = ''
-        section_keys = self.config_dict.keys()
-        for section_item in section_keys:
-            content += '[' + section_item + ']\n'
-            section_dict = self.config_dict[section_item]
-            section_keys = section_dict.keys()
-            for key in section_keys:
-                val = section_dict[key]
-                content += key + ' = ' + val + '\n'
-            content += '\n'
-        return content
-
-    def write(self, file_name):
-        print('Error: write() method not implemented')
-        raise
-        self.content = self.__str__(self)
-        print(self.content)
-
-    def read_string(self, content):
-        self.content = content
-        self._parse()
-
-    def read(self, file_name):
-        print('Error: read() method not implemented')
-        raise
-        content = ''
-        self.content = content
-        self._parse()
-
-def _getvalue(stmt):
-    index = 0
-    val = ''
-    for item in stmt:
-        if index > 0:
-            if val != '':
-                val += ('=' + item)
-            else:
-                val += item
-        index = index + 1
-    return val

+ 1 - 1
packages.toml

@@ -157,7 +157,7 @@ releases = [
 
 
 [[packages]]
-name = "pika_configparser"
+name = "configparser"
 releases = [
   "v0.0.1 571ceb837b7a912e3a8e4ae342767f4fb1eb7a9e",
 ]

+ 1 - 1
port/linux/package/pikascript/main.py

@@ -11,7 +11,7 @@ import cjson_test
 import test_module4
 import pika_lua
 import import_test
-import pika_configparser
+import configparser
 import PikaDebug
 import PikaCV
 import binascii

+ 0 - 112
port/linux/package/pikascript/pika_configparser.py

@@ -1,112 +0,0 @@
-from PikaStdData import String
-
-class ConfigParser():
-    content = ''
-    config_dict = {}
-
-    def _parse(self):
-        self.content = String(self.content).replace('\r', '')
-        content = String(self.content)
-        lines = content.split('\n')
-        for line in lines:
-            line = String(line)
-            if line.startwith('#'):
-                continue
-            if line.startwith(';'):
-                continue
-            if line.startwith('['):
-                section = String(line.replace('[', ''))
-                section = section.replace(']', '')
-                self.config_dict[section] = {}
-                continue
-
-            if line.strip() == '':
-                continue
-
-            stmt = line.split('=')
-            key = String(stmt[0]).strip()
-            value = String(_getvalue(stmt)).strip()
-            section_dict = self.config_dict[section]
-            section_dict[key] = value
-
-    def sections(self):
-        section_keys = self.config_dict.keys()
-        sections = []
-        for section_item in section_keys:
-            sections.append(section_item)
-        return sections
-
-    def options(self, section):
-        section_dict = self.config_dict[section]
-        option_keys = section_dict.keys()
-        options = []
-        for option_item in option_keys:
-            options.append(option_item)
-        return options
-
-    def get(self, section, option):
-        section_dict = self.config_dict[section]
-        return section_dict[option]
-
-    def set(self, section, option, value):
-        section_dict = self.config_dict[section]
-        section_dict[option] = value
-
-    # support config[key] = val
-    def __set__(self, __key, __val):
-        self.config_dict[__key] = __val
-
-    # support val = config[key]
-    def __get__(self, __key):
-        return self.config_dict[__key]
-
-    def items(self, section):
-        section_dict = self.config_dict[section]
-        section_keys = section_dict.keys()
-        items = []
-        for key in section_keys:
-            val = section_dict[key]
-            items.append([key, val])
-        return items
-
-    def __str__(self):
-        content = ''
-        section_keys = self.config_dict.keys()
-        for section_item in section_keys:
-            content += '[' + section_item + ']\n'
-            section_dict = self.config_dict[section_item]
-            section_keys = section_dict.keys()
-            for key in section_keys:
-                val = section_dict[key]
-                content += key + ' = ' + val + '\n'
-            content += '\n'
-        return content
-
-    def write(self, file_name):
-        print('Error: write() method not implemented')
-        raise
-        self.content = self.__str__(self)
-        print(self.content)
-
-    def read_string(self, content):
-        self.content = content
-        self._parse()
-
-    def read(self, file_name):
-        print('Error: read() method not implemented')
-        raise
-        content = ''
-        self.content = content
-        self._parse()
-
-def _getvalue(stmt):
-    index = 0
-    val = ''
-    for item in stmt:
-        if index > 0:
-            if val != '':
-                val += ('=' + item)
-            else:
-                val += item
-        index = index + 1
-    return val

+ 1 - 1
port/linux/package/pikascript/pika_configparser_test.py

@@ -1,4 +1,4 @@
-import pika_configparser as configparser
+import configparser as configparser
 from PikaStdLib import MemChecker
 config = configparser.ConfigParser()
 

+ 0 - 100
port/linux/package/pikascript/pikascript-lib/pika_configparser/pika_configparser.py

@@ -1,100 +0,0 @@
-from PikaStdData import String
-
-
-class ConfigParser():
-    content = ''
-    config_dict = {}
-
-    def _parse(self):
-        content = String(self.content)
-        lines = content.split('\n')
-        for line in lines:
-            line = String(line)
-            if line.startwith('#'):
-                continue
-            if line.startwith('['):
-                section = String(line.replace('[', ''))
-                section = section.replace(']', '')
-                self.config_dict[section] = {}
-                continue
-
-            if line.strip() == '':
-                continue
-
-            stmt = line.split('=')
-            key = String(stmt[0])
-            value = String(stmt[1])
-            key = key.strip()
-            value = value.strip()
-            section_dict = self.config_dict[section]
-            section_dict[key] = value
-
-    def sections(self):
-        section_keys = self.config_dict.keys()
-        sections = []
-        for section_item in section_keys:
-            sections.append(section_item)
-        return sections
-
-    def options(self, section):
-        section_dict = self.config_dict[section]
-        option_keys = section_dict.keys()
-        options = []
-        for option_item in option_keys:
-            options.append(option_item)
-        return options
-
-    def get(self, section, option):
-        section_dict = self.config_dict[section]
-        return section_dict[option]
-
-    def set(self, section, option, value):
-        section_dict = self.config_dict[section]
-        section_dict[option] = value
-
-    # support config[key] = val
-    def __set__(self, __key, __val):
-        self.config_dict[__key] = __val
-
-    # support val = config[key]
-    def __get__(self, __key):
-        return self.config_dict[__key]
-
-    def items(self, section):
-        section_dict = self.config_dict[section]
-        section_keys = section_dict.keys()
-        items = []
-        for key in section_keys:
-            val = section_dict[key]
-            items.append([key, val])
-        return items
-
-    def __str__(self):
-        content = ''
-        section_keys = self.config_dict.keys()
-        for section_item in section_keys:
-            content += '[' + section_item + ']\n'
-            section_dict = self.config_dict[section_item]
-            section_keys = section_dict.keys()
-            for key in section_keys:
-                val = section_dict[key]
-                content += key + ' = ' + val + '\n'
-            content += '\n'
-        return content
-
-    def write(self, file_name):
-        print('Error: write() method not implemented')
-        raise
-        self.content = self.__str__(self)
-        print(self.content)
-
-    def read_string(self, content):
-        self.content = content
-        self._parse()
-
-    def read(self, file_name):
-        print('Error: read() method not implemented')
-        raise
-        content = ''
-        self.content = content
-        self._parse()

+ 2 - 2
port/linux/test/configparser-test.cpp

@@ -24,8 +24,8 @@ TEST(configparser, test1) {
     /* run */
     obj_setStr(pikaMain, "s", s);
     obj_run(pikaMain,
-            "import pika_configparser\n"
-            "config = pika_configparser.ConfigParser()\n"
+            "import configparser\n"
+            "config = configparser.ConfigParser()\n"
             "config.read_string(s)\n");
     /* collect */
     /* assert */

+ 1 - 1
port/linux/test/parse-test.cpp

@@ -3341,7 +3341,7 @@ TEST(parser, def_issue1) {
 
 TEST(parser, configparser) {
     Args buffs = {0};
-    Parser_fileToAsm(&buffs, "package/pikascript/pika_configparser.py");
+    Parser_fileToAsm(&buffs, "package/pikascript/configparser.py");
     strsDeinit(&buffs);
 }