Comments (7)
Hello. Would you please be so kind and provide me a patch / diff ?
from hiyapyco.
Index: hiyapyco/init.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
--- hiyapyco/init.py (revision 8ab38a0)
+++ hiyapyco/init.py (date 1582205392539)
@@ -65,9 +65,11 @@
you may set this to something suitable for you
jinja2env = Environment(undefined=Undefined)
-METHODS = { 'METHOD_SIMPLE':0x0001, 'METHOD_MERGE':0x0002 }
+METHODS = { 'METHOD_SIMPLE':0x0001, 'METHOD_MERGE':0x0002, 'METHOD_SUBSTITUTE':0x0003 }
METHOD_SIMPLE = METHODS['METHOD_SIMPLE']
METHOD_MERGE = METHODS['METHOD_MERGE']
+METHOD_SUBSTITUTE = METHODS['METHOD_SUBSTITUTE']
+
class HiYaPyCo():
"""Main class"""
@@ -75,8 +77,8 @@
"""
args: YAMLfile(s)
kwargs:
-
* method: one of hiyapyco.METHOD_SIMPLE | hiyapyco.METHOD_MERGE
-
* mergelists: boolean (default: True) try to merge lists (only makes sense if hiyapyco.METHOD_MERGE)
-
* method: one of hiyapyco.METHOD_SIMPLE | hiyapyco.METHOD_MERGE | hiyapyco.METHOD_SUBSTITUTE
-
* mergelists: boolean (default: True) try to merge lists (only makes sense if hiyapyco.METHOD_MERGE or hiyapyco.METHOD_SUBSTITUTE) * interpolate: boolean (default: False) * castinterpolated: boolean (default: False) try to cast values after interpolating * usedefaultyamlloader: boolean (default: False)
@@ -238,6 +240,8 @@
else:
if self.method == METHOD_SIMPLE:
self._data = self._simplemerge(self._data, ydata)
-
elif self.method == METHOD_SIMPLE:
-
self._data = self._deepmerge(self._data, ydata) else: self._data = self._deepmerge(self._data, ydata) logger.debug('merged data: %s' % self._data)
@@ -329,6 +333,50 @@
(type(b), type(a), a, b,)
)
return a
+
-
def __substmerge(self, a, b):
-
logger.debug('>' * 30)
-
logger.debug('deepmerge %s and %s' % (a, b,))
-
# FIXME: make None usage configurable
-
if b is None:
-
logger.debug('pass as b is None')
-
pass
-
# treat listTypes as primitiveTypes in merge
-
# subsititues list, don't merge them
-
if a is None or isinstance(b, primitiveTypes) or isinstance(b, listTypes):
-
logger.debug('deepmerge: replace a "%s" w/ b "%s"' % (a, b,))
-
a = b
-
elif isinstance(a, dict):
-
if isinstance(b, dict):
-
logger.debug('deepmerge: dict ... "%s" and "%s"' % (a, b,))
-
for k in b:
-
if k in a:
-
logger.debug('deepmerge dict: loop for key "%s": "%s" and "%s"' % (k, a[k], b[k],))
-
a[k] = self._deepmerge(a[k], b[k])
-
else:
-
logger.debug('deepmerge dict: set key %s' % k)
-
a[k] = b[k]
-
elif isinstance(b, listTypes):
-
logger.debug('deepmerge: dict <- list ... "%s" <- "%s"' % (a, b,))
-
for bd in b:
-
if isinstance(bd, dict):
-
a = self._deepmerge(a, bd)
-
else:
-
raise HiYaPyCoImplementationException(
-
'can not merge element from list of type %s to dict (@ "%s" try to merge "%s")' %
-
(type(b), a, b,)
-
)
-
else:
-
raise HiYaPyCoImplementationException(
-
'can not merge %s to %s (@ "%s" try to merge "%s")' %
-
(type(b), type(a), a, b,)
-
)
-
logger.debug('end deepmerge part: return: "%s"' % a)
-
logger.debug('<' * 30)
-
return a
def _deepmerge(self, a, b):
logger.debug('>'*30)
@@ -436,8 +484,8 @@args: YAMLfile(s)
kwargs:
-
* method: one of hiyapyco.METHOD_SIMPLE | hiyapyco.METHOD_MERGE
-
* mergelists: boolean (default: True) try to merge lists
-
* method: one of hiyapyco.METHOD_SIMPLE | hiyapyco.METHOD_MERGE | hiyapyco.METHOD_SUBSTITUTE
-
* mergelists: boolean (default: True) try to merge lists (only makes sense if hiyapyco.METHOD_MERGE or hiyapyco.METHOD_SUBSTITUTE) * interpolate: boolean (default: False) * castinterpolated: boolean (default: False) try to cast values after interpolating * usedefaultyamlloader: boolean (default: False)
from hiyapyco.
My comment above is proposed patch. Sorry for formatting issues.
from hiyapyco.
sorry, I need something usable.
can you please fork the repo and commit your proposes changes into the fork?
and maybe you can even create a pull request then ...
Greetings
from hiyapyco.
You should be more clear about this. Uploading patch as attachment.
from hiyapyco.
Please, see #37
from hiyapyco.
PR #37 merged
released 0.4.16
from hiyapyco.
Related Issues (20)
- what are the requirements for this package? HOT 2
- is there a way to use ruamel YAML isntead of pyyaml? HOT 1
- Jinja2 dependency increased to include Jinja2 3.x.x HOT 1
- How do you specify jinja variables in yaml files for interpolation? HOT 7
- release pr #42 HOT 2
- Cannot import name 'soft_unicode' from 'markupsafe' HOT 3
- bring python build process up to date
- github actions HOT 1
- List Items order matters? HOT 1
- ansible !vault variable not load HOT 1
- how add !vault tag HOT 9
- update outdated dependencies HOT 2
- Versioned release HOT 1
- optional: support python3-ruamel HOT 1
- racially loaded terms - rename default branch to main HOT 1
- Wrong Recursive call on method _substmerge HOT 8
- remove deprecated distutils HOT 3
- extend tests to debian 12 HOT 1
- pypi release fails: The description failed to render in the default format of reStructuredText. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hiyapyco.