Skip to content

Commit

Permalink
Merge pull request #5 from naamancampbell/issue-3
Browse files Browse the repository at this point in the history
resolves:#3 Retains userContextIds
  • Loading branch information
naamancampbell authored Dec 14, 2020
2 parents a60bf05 + 32cd8ff commit 0111e20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.5.1
------------------
* Retains userContextIds

1.4.1
------------------
* Support multiple Firefox profiles
Expand Down
23 changes: 2 additions & 21 deletions ff_containers_sort/ff_containers_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
## Author: Naaman Campbell
## 12 December 2020
##
## Version: 1.4.1 | 2020-12-14 - NC | Support multiple Firefox profiles
## Version: 1.5.1 | 2020-12-14 - NC | Retains userContextIds
## See CHANGELOG.md for full details
##
## Sources:
Expand Down Expand Up @@ -61,6 +61,7 @@ def sort_containers(conf_filename, sort, manual):
conf = json.load(conf_file)

public_identities = [i for i in conf['identities'] if i['public']]
private_identities = [i for i in conf['identities'] if not i['public']]

if sort:
# only sort custom identities
Expand Down Expand Up @@ -105,26 +106,6 @@ def sort_containers(conf_filename, sort, manual):
# sort public identities
public_identities = [public_identities[int(i) - 1] for i in new_order]

# determine reserved ids for private identities
private_identities = [i for i in conf['identities'] if not i['public']]
reserved_ids = [
item['userContextId']
for item in private_identities
if item['userContextId'] < public_identities_count
]

# generate list of ids with reserved ids removed
public_ids = list(
range(1, (public_identities_count + 1) + len(reserved_ids))
)
for resv_id in reserved_ids:
public_ids.remove(resv_id)

# re-number 'public' Container objects
for item in public_identities:
public_ids.reverse()
item['userContextId'] = public_ids.pop()

conf['identities'] = public_identities + private_identities

with open(conf_filename, 'w') as conf_file:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="ff-containers-sort",
version="1.4.1",
version="1.5.1",
author="Naaman Campbell",
author_email="[email protected]",
description="Sorts and re-numbers Firefox Containers config objects in Firefox containers.json",
Expand Down

0 comments on commit 0111e20

Please sign in to comment.