python – What is best practice for getting a variable passed into a function several layers deep in a local function call?

I have a situation as follows, I have a relative path that I want to get for a directory. The directory structure is as follows,

Windows Folder Structure

C:FileFolderLowerLevelThirdLevelscript.py

C:FileFolderFolderOfInterestfilesStuff.txt

Linux Structure

PathAbove/LowerLevel/ThirdLevel/script.py

PathAbove/FileFolder/FolderOfInterest/filesStuff.txt


Top Level

args = parse_args(sys.argv(1:))
main(args.filepath, args.repository)

Function Definitions

main(filepath,repopath)
{
//do stuff with filepath, repopath
    do_stuff()
    
}

do_stuff()
   path_to_repo = rel_path()  
   #use path_to_repo 




def rel_path():
    """
    Gets the relative path two directory levels up where FileFolder folder lives
    """
    return os.path.abspath(os.path.join(os.path.dirname( __file__), '../../', 'FileFolder/FolderOfInterest'))

I have been asked to make this more general so I don’t have to rely on the FileFolder name being ‘FileFolder’ in case somebody has it named differently.

I pass in the path directly to repopath at the start, so I could use that since it’s validated before use. My usual solution is this

My Usual Solution

Pass repository_path from the top level.

main(args.filepath,args.repository)
    repository_path = args.repository

    do_stuff(repository_path)
        rel_path(repository_path)
    def rel_path(repository_path):
        """
        Gets the relative path two directory levels up where galaxy folder lives
        """
        return os.path.abspath(os.path.join(os.path.dirname( repository_path ), '/FileOfInterest'))

It comes up often that I need to pass in information from a higher level function to a lower level function, usually after I realize that info is needed and I want to refactor something to use it for whatever reason. This requires adding an extra argument to multiple functions and changing functionality slightly. There is actually a third function in-between this in my real code, but this illustrates the issue.

Here is my question

My question is this, is there a best practice for passing in information to a lower level function used only inside another function that isn’t called by the main function? Or am I way off base here? Is there any easier way to get the relative path of FolderOfInterest that I’m interested in getting? Typically I have historically programmed in procedural languages and this has come up plenty of times before in the past. But, it also comes up in OOP programming I’ve done before.

This comes up often enough that I thought it was worth asking here. How do I pass information around without requiring rework of multiple parts of my code when that information is embedded at a higher level than where it needs to be used? I’m trying to make this as agnostic as possible with relative paths, function arguments so it’s easier for others to use/modify later, and so people using it don’t have to make changes depending on whether they run it on Linux or Windows.

I hope I’ve written this somewhat clear and this is a useful enough question to be here. I originally had this on stackoverflow, but since it’s more about best practices in software engineering, I put it here.

I’ve marked this as python because that’s what I’m writing in, but this comes up just as much in c, matlab, c++, and other languages I’ve written in that I’m not necessarily tied to the answer being specific to python syntax

Create your own whatsapp app for your privacy for $125

Create your own whatsapp app for your privacy

As of now WhatsApp issues are going on most of the people will reduce use of WhatsApp due privacy issue .

so here we provide your own WhatsApp with following features.

-encrypted

-fully private

-fully safe-more advance

-customizable-you can share upto 1.5gb fileAnd unlimitedYou can also earn money from it

.

linux – Iptables Forward All traffic to different interface except local inter-lan

I have Two LAN

Local LAN: 172.30.30.0/24 with gw 172.30.30.254

Remote LAN : 192.168.2.0/24 with gw 192.168.2.1

both lan can communicate and ping each other devices.

i have introduce new machine 172.30.30.10 and set all 172.30.30.0/24 devices gateway to this ip.

I need to to forward all traffic to 172.30.30.10’s eth0 >>> tun0 interface except there local inter-lan communication.

So what i have done till now is

    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
    iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
    ip route add -net 192.168.2.0/24 gw 172.30.30.254 dev eth0 metric 101

So after this i am able to ping from 172.30.30.0/24 network to 192.168.2.0/24 and vice versa

but when the tun0 interface create after connecting to the vpn only one way ping happen 172.30.30.0/24 to 192.168.2.0/24 NOT vice versa.

What else can i do so that it can ping each other network even after connecting to vpn(tun0 interface)?

8 – Is it possible to do Drupal Development without a local development environment?

I am used to having Virtualbox and linux running on my local to do development work. My new client has a migration project for me to do but they do not allow any local development tools like xamp, dev desktop, Vagrant, Virtualbox. They are a government client and they want us to use their laptops and work on their network in their office. They are not very tech savvy They also do not want to use Git. The client asked that I do all the work on their staging redhat server then clone it to the production server. Their project is to turn 2 static html websites into Drupal CMS. The sites consist of a 80 pages and about 200  PDF files that users search for and download. Does anyone have any ideas of how to approach this project? We cannot place their website content on our personal laptops. But I should be able to build the theme and content types on my personal laptop. 

My plan was to let them install Drupal 8 on the stage server. Then I will download the site and sql file. Copy the site over to my personal laptop which has Virtualbox. ( I will need to get permission to do this) Then build the subtheme, content types and add the needed fields to all content types. Basically get it ready to import CSV spreadsheet. Export and import these changes to the stage server and upload the new theme. Then create the CSV spreadsheets based on the clients website pages and pdf files. Create the migration scripts and import content directly on the staging server. That is what I though I could do. If you have ideas please let me know. Thank you

I will boost google ranking with monthly local SEO services for $120

I will boost google ranking with monthly local SEO services

Get Google page #1 Ranking, leads, and branding with 2021 SEO trends.Please share the following information so that I will get back to you with the latest 2021 SEO roadmap Strategy according to updated Google Algorithms.

  • Website URL
  • Keywords If any
  • Competitors
  • Geographical area that you want to target.

Check-out the demonstration of my deep analysis, strategy roadmap, get to know my skills through the analyzed document, and then decide to hire.What you will get with this Gig :

  • Help you to take the best SEO package for your business.
  • Only Whitehat techniques.
  • Weekly Reporting.
  • 100% Client Delight.
  • Content-based SEO.

Note: We don’t work with adult or casino sites. Recent Results: 230+ Keywords Ranked in the last six months.

.

I will create 300 google maps point citations for local SEO for your business for $5

I will create 300 google maps point citations for local SEO for your business

Hi, I am SEO Boss Local SEO and off-page SEO experts. I will build (300+/1000 +/2000+) Google map point Listing AAA SEO. Local Map Point listings help to boost Google place ranking and local business online. The work is a powerhouse of link-juice for your Local SEO. I have been working in the industry for the past 4 years

Basic : $5
300 Maps Citations + 5 Driving Directions + 5 LIVE Local Citations Backlinks + 10 miles Radius Cover -delivery 2days
Standard: $15
1000 Maps Citations + 10 Driving Directions + 10 LIVE Local Citations Backlinks + 20 Miles Radius Cover -delivery 3days
Premium gig: $30
2000 Maps Citations + 15 Driving Directions + 25 LIVE Local Citations Backlinks +35 Miles Radius Cover- delivery 5days

Why you need this?

  • Increase Social Buzz in Local Area
  • Best for Local and Maps rankings
  • Google Panda, Hummingbird, and Penguin safe
  • 100% Name, Address, Phone (NAP) Consistency on Google Maps
  • Manual Submissions with live links in the report
  • Fastest delivery

Why Me ?

  • Best for Local and Maps rankings.
  • NAP Constant for ALL Citations.
  • Your Business address show up in Maps
  • Why Choose Me?
  • On-time Delivery
  • Quality first
  • Do not take more work at a time
  • 100% Money-back guarantee
  • Full Reports Submission (excel format)
  • 100% Satisfied Customers.
  • I trust Long Term relationship
  • 24/7 days service and support.

I believe in quality, not quantity

.(tagsToTranslate)mapcitation(t)googlemap(t)seo(t)localseo(t)localcitation