Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues #108 and #124. #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Adam Fineman <[email protected]>
adam-fineman marked this conversation as resolved.
Show resolved Hide resolved
Di Xu <[email protected]>
Felipe Ruhland <[email protected]>
stephenhsu <[email protected]>
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CHANGES
=======

* Fixes issue #124
adam-fineman marked this conversation as resolved.
Show resolved Hide resolved
* remove broken PyPI downloads badge and add saythanks badge

0.6.0
-----

Expand Down
19 changes: 11 additions & 8 deletions rtcclient/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,23 @@ def __initialize(self, resp):
def __initializeFromRaw(self):
"""Initialze from raw data (OrderedDict)"""

attr_map = self.rtc_obj.attribute_map
if attr_map is None:
attr_map = {}

for (key, value) in self.raw_data.items():
if key.startswith("@"):
# be compatible with IncludedInBuild
if "@oslc_cm:label" != key:
continue

attr = key.split(":")[-1].replace("-", "_")
attr_list = attr.split(".")

# ignore long attributes
if len(attr_list) > 1:
# attr = "_".join([attr_list[-2],
# attr_list[-1]])
continue
if key in attr_map:
attr = attr_map[key]
else:
# ignore long attributes
if '.' in key:
continue
attr = key.split(":")[-1].replace("-", "_")

self.field_alias[attr] = key

Expand Down
8 changes: 7 additions & 1 deletion rtcclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class RTCClient(RTCBase):
the url ends with 'jazz', otherwise to `False` if with 'ccm'
(Refer to issue #68 for details)
:type ends_with_jazz: bool
:param attribute_map: (optional) Dictionary mapping RTC attributes to
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't get what this attribute_map is for.

If you want to know all the alias, you can refer to field_alias. See this link.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attribute_map does two things:

  1. It allows overriding the alias that is automatically created in FieldBase.__initializeFromRaw.
  2. It is the mechanism for forcing the inclusion of an attribute with a "." in the name, which is the specific fix for issue Properties with "." in the name are not accessible #108

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. Just following up. Is there anything else I can do to move this along?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can field_alias in this link be used, instead of having a new attribute_map ?

keys. If ommitted, the default mapping will be, for example,
{'ns:some-attr': 'some_attr', 'other_ns:otherattr': 'otherattr', ...}
Also, long attributes with dots in their names will be discarded
unless present in the `attribute_map`.

Tips: You can also customize your preferred properties to be returned
by specified `returned_properties` when the called methods have
Expand All @@ -47,7 +52,7 @@ class RTCClient(RTCBase):
log = logging.getLogger("client.RTCClient")

def __init__(self, url, username, password, proxies=None, searchpath=None,
ends_with_jazz=True):
ends_with_jazz=True, attribute_map=None):
"""Initialization

See params above
Expand All @@ -56,6 +61,7 @@ def __init__(self, url, username, password, proxies=None, searchpath=None,
self.username = username
self.password = password
self.proxies = proxies
self.attribute_map = attribute_map
RTCBase.__init__(self, url)

if not isinstance(ends_with_jazz, bool):
Expand Down
18 changes: 11 additions & 7 deletions rtcclient/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,22 @@ def _remove_long_fields(self, wk_raw_data):

match_str_list = ["rtc_cm:com.ibm.",
"calm:"]
to_delete = []
for key in wk_raw_data.keys():
for match_str in match_str_list:
if key.startswith(match_str):
try:
wk_raw_data.pop(key)
self.log.debug("Successfully remove field [%s] from "
"the template", key)
except:
self.log.warning("Cannot remove field [%s] from the "
"template", key)
to_delete.append(key)
continue

for key in to_delete:
try:
del wk_raw_data[key]
self.log.debug("Successfully removed field [%s] from "
"the template", key)
except:
self.log.warning("Cannot remove field [%s] from the "
"template", key)

def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8"):
"""Get templates from a group of to-be-copied :class:`Workitems` and
Expand Down