Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 2d0b2ed

Browse files
committed
Conversion Mode Selection
1 parent e60e4fc commit 2d0b2ed

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎Scripts/Miscellaneous/CHMOD_simplifier/chmod_simplifier.py‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
notation = {
24
'---': '0',
35
'--x': '1',
@@ -9,7 +11,7 @@
911
'rwx': '7'
1012
}
1113

12-
def perm_to_num(symbolic):
14+
def symb_to_num(symbolic):
1315
'''
1416
Convert symbolic permission notation to numeric notation.
1517
'''
@@ -21,11 +23,11 @@ def perm_to_num(symbolic):
2123
except:
2224
numeric = "Invalid Symbolic Representation!"
2325
else:
24-
numeric = "Symbolic input should be for lengh 9!"
26+
numeric = "Symbolic input should be of lengh 9!"
2527

2628
return numeric
2729

28-
def num_to_perm(num):
30+
def num_to_symb(num):
2931
'''
3032
Convert number permission notation to symbolic notation.
3133
'''
@@ -46,5 +48,19 @@ def num_to_perm(num):
4648

4749
return symbolic
4850

51+
def main():
52+
representation = sys.argv[1]
53+
mode = sys.argv[2]
54+
if mode == 'S':
55+
print(num_to_symb(representation))
56+
elif mode == 'N':
57+
print(symb_to_num(representation))
58+
else:
59+
print("Invalid Mode Selection. Please select 'S' for numerical --> symbolic conversion or 'N' for symbolic --> numerical conversion!")
60+
61+
if __name__ == "__main__":
62+
main()
63+
64+
65+
4966

50-
print(num_to_perm(700))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /