ini

Read all the contents in ini file into dictionary with Python

只愿长相守 提交于 2019-11-27 04:19:41
问题 Normally, I code as follows for getting a particular item in a variable as follows try: config = ConfigParser.ConfigParser() config.read(self.iniPathName) except ConfigParser.MissingSectionHeaderError, e: raise WrongIniFormatError(`e`) try: self.makeDB = config.get("DB","makeDB") except ConfigParser.NoOptionError: self.makeDB = 0 Is there any way to read all the contents in a python dictionary? For example [A] x=1 y=2 z=3 [B] x=1 y=2 z=3 is written into val["A"]["x"] = 1 ... val["B"]["z"] = 3

How do I write Routing Chains for a Subdomain in Zend Framework in a routing INI file?

让人想犯罪 __ 提交于 2019-11-27 02:31:30
问题 I am trying to create a subdomain using the Zend Router, and then for each section under a subdomain, such as subdomain.site.com/section/ I am creating another route and then trying to chain it to the subdomain route. but I don't know how. I have read all the documentation I could find and all the forums, but it leads me to figure it out on my own. So far, my attempts just get me this error: Catchable fatal error: Argument 2 passed to Zend_Controller_Router_Rewrite::addRoute() must implement

parsing .properties file in Python

牧云@^-^@ 提交于 2019-11-26 21:43:06
The ConfigParser module raises an exception if one parses a simple Java-style .properties file, whose content is key-value pairs (i..e without INI-style section headers). Is there some workaround? Alex Martelli Say you have, e.g.: $ cat my.props first: primo second: secondo third: terzo i.e. would be a .config format except that it's missing a leading section name. Then, it easy to fake the section header: import ConfigParser class FakeSecHead(object): def __init__(self, fp): self.fp = fp self.sechead = '[asection]\n' def readline(self): if self.sechead: try: return self.sechead finally: self

Registry vs. INI file for storing user configurable application settings

风流意气都作罢 提交于 2019-11-26 19:33:40
问题 I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the values after the user hits the Apply button on that form? What are the pros and cons of storing settings in the Windows registry vs. storing them in a local INI file or config file or similar? 回答1: Pros of config file:

How to expand environment variables in .ini files using Boost

我的未来我决定 提交于 2019-11-26 18:35:24
问题 I have a INI file like [Section1] Value1 = /home/%USER%/Desktop Value2 = /home/%USER%/%SOME_ENV%/Test and want to parse it using Boost. I tried using Boost property_tree like boost::property_tree::ptree pt; boost::property_tree::ini_parser::read_ini("config.ini", pt); std::cout << pt.get<std::string>("Section1.Value1") << std::endl; std::cout << pt.get<std::string>("Section1.Value2") << std::endl; But it didn't expand the environment variable. Output looks like /home/%USER%/Desktop /home/

How to parse ini file with Boost

萝らか妹 提交于 2019-11-26 18:24:48
I have a ini file which contains some sample values like: [Section1] Value1 = 10 Value2 = a_text_string I'm trying to load these values and print them in my application with Boost but I don't understand how to do this in C++. I searched in this forum in order to find some examples (I always used C and so I'm not very good in C++) but I found only examples about how to read values from file all at once. I need to load just a single value when I want, like string = Section1.Value2 because I don't need to read all the values, but just few of them. I'd like to load single values and to store them

How to read and write to an ini file with PHP

你说的曾经没有我的故事 提交于 2019-11-26 17:35:58
I've been looking around the official php documentation but I'm unable to find what I'm looking for. http://php.net/manual/en/function.parse-ini-file.php I just want a function to edit and read the value from the php ini file, for instance, [default_colors] sitebg = #F8F8F8 footerbg = #F8F8F8 link = #F8F8F8 url = #F8F8F8 bg = #F8F8F8 text = #F8F8F8 border = #F8F8F8 lu_link = #F8F8F8 lu_url = #F8F8F8 lu_bg = #F8F8F8 lu_text = #f505f5 lu_border = #F8F8F8 How do I read the value belonging to "lu_link" or "footerbg"? How to I write a new value for these places? Winfield Trail The PEAR Config_Lite

Cross-platform way to get line number of an INI file where given option was found

前提是你 提交于 2019-11-26 16:44:20
Looking for some C++ library (like boost::program_options) that is able to return line number of an INI file, where the given option or section was found. Use cases: I ask that library to find value "vvv" in a section "[SSS]". Library returns line number where "vvv" in section "[SSS]" is found, or -1. It gives me an ability to say "line 55: vvv must be < 256". I iterate INI file for sections and validate their names. When some wild secsion is found, i tell: "line 55: section [Hahaha] is unknown". update: i know about "INI is older than mammoth", but currently i have to port large windows

PHP Warning: Module already loaded in Unknown on line 0

元气小坏坏 提交于 2019-11-26 16:04:24
问题 On Mac OSX Mavericks using homebrew php55 whenever I run a a php command I get the following error message (everything runs fine it's just annoying) PHP Warning: Module 'intl' already loaded in Unknown on line 0 I ran php --ini and the output was php --ini PHP Warning: Module 'intl' already loaded in Unknown on line 0 Warning: Module 'intl' already loaded in Unknown on line 0 Configuration File (php.ini) Path: /usr/local/etc/php/5.5 Loaded Configuration File: /usr/local/etc/php/5.5/php.ini

Windows batch script to read an .ini file

谁说胖子不能爱 提交于 2019-11-26 15:20:59
I'm trying to read an .ini file with the following format: [SectionName] total=4 [AnotherSectionName] total=7 [OtherSectionName] total=12 Basically I want to print out certain values from the .ini file, for example the total under OtherSectionName followed by the total from AnotherSectionName . paxdiablo Here's a command file ( ini.cmd ) you can use to extract the relevant values: @setlocal enableextensions enabledelayedexpansion @echo off set file=%~1 set area=[%~2] set key=%~3 set currarea= for /f "usebackq delims=" %%a in ("!file!") do ( set ln=%%a if "x!ln:~0,1!"=="x[" ( set currarea=!ln!