I'm back. I have my first _working_ python script! Woot! It takes a Cisco ASA config, and converts certain aspects (network objects, services objects, access-list)(the ones I need) to a Fortinet stanza. (Vendor A to Vendor B).
So it works. But in the interest of being a n00b, I'd like feedback & constructive criticism. (You can't hurt my feelings, the ex-wife got those along with the house).
It's ~650 lines. Post it here in the forum? provide a google drive link? What's proper forum etiquette?
I was looking at other peoples code and snippets, and just a bit of self critique:::
1) I don't have a _main_... but it works, so do I _need_ one, or is it simply best_practice to have one?
-- yea, but it works, so obviously not REQUIRED
2) I couldn't get (var_1, var_2 +=1 ) so I increment each on it's own line
-- wasn't sure what to google exactly for what I was trying to do
3) I create an object of an existing object simply to make it more readable
-- having too long a name or non-intuitive name made it confusing to debug
--here's what I did ::: acl_line = original_lines[counter].split() & used acl_line rather than original_lines
4) Variables -- I saw a code snippet saying certain things should be set to Global.
-- really not sure why or how some objects are known in a function, while only some are passed
-- RTFM time?
5) I have more If/elif/elif/else statements than Canada has Tim Horton's.
-- it's okay because it's a parser and you have to do all those checks... or hey idiot, there's a better way called XYZ
-- I couldn't find a "CASE" statement in python, is it called something else?
6) I wrote a line de-duplicator - is there a better way
-- actually thought i handled it pretty well....wait, what are you doing with that pin ??? <POP!!>
So, post code or no?
Thanks,
PappaBear
Code now at::: https://github.com/PappaBearTroy/FWConverter
So it works. But in the interest of being a n00b, I'd like feedback & constructive criticism. (You can't hurt my feelings, the ex-wife got those along with the house).
It's ~650 lines. Post it here in the forum? provide a google drive link? What's proper forum etiquette?
I was looking at other peoples code and snippets, and just a bit of self critique:::
1) I don't have a _main_... but it works, so do I _need_ one, or is it simply best_practice to have one?
-- yea, but it works, so obviously not REQUIRED
2) I couldn't get (var_1, var_2 +=1 ) so I increment each on it's own line
-- wasn't sure what to google exactly for what I was trying to do
3) I create an object of an existing object simply to make it more readable
-- having too long a name or non-intuitive name made it confusing to debug
--here's what I did ::: acl_line = original_lines[counter].split() & used acl_line rather than original_lines
4) Variables -- I saw a code snippet saying certain things should be set to Global.
-- really not sure why or how some objects are known in a function, while only some are passed
-- RTFM time?
5) I have more If/elif/elif/else statements than Canada has Tim Horton's.
-- it's okay because it's a parser and you have to do all those checks... or hey idiot, there's a better way called XYZ
-- I couldn't find a "CASE" statement in python, is it called something else?
6) I wrote a line de-duplicator - is there a better way
-- actually thought i handled it pretty well....wait, what are you doing with that pin ??? <POP!!>
So, post code or no?
Thanks,
PappaBear
Code now at::: https://github.com/PappaBearTroy/FWConverter