Is there a way to import a class module (psm1) into another class module (psm1)? - powershell

I have two class modules. Each in its file. I'd like to use Class1.psm1 inside Class2.psm1.
I am using: using module '.\path'
but I get this error Unable to find type [Class1].
Is there a way to do that in powershell 5.1?

Related

install4j how to parse json in a form component

I'm trying to parse json in an action script for a form component.
I tried to:
import javax.json.JsonObject;
And get the following on a test compile:
Failed to compile script
1. ERROR in /private/var/folders/3t/l3dvn7tx1j76wsx17xfjcpww0000gn/T/script10053200329813627000.java.dir/code/Completion.java (at line 1)
import javax.json.JsonObject;
The import javax.json cannot be resolved
How do I achieve the equivalent of this import so I can parse json? I started going down the rabbit hole of create a JMOD for javax.json but that's starting to seem like the wrong path.
The package javax.json is not part of the JRE, but a JEE 7 API. You can download the JAR file from
https://mvnrepository.com/artifact/javax.json/javax.json-api/1.1.4
and add it on the "Installer->Screens & Actions->Custom code" step. Then the class will be available in all scripts.

How to import module up multiple levels from base?

I'm trying to call a module several levels up from pytest run directory. How do I import this module?
I've tried:
sys.path.insert(0, 'path/to/module')
import modulename
Here's the directory structure:
tools
common
modulename.py (contains class A)
functional_test (this is where I'm running pytest; tools/functional_test)
conftest.py
pytest.ini
tests
typea (this is tools/funtional_tests/tests/typea)
tests_typea1.py
Under tests_typea1.py, I want to import class A from modulename.py under tools/common.
Getting the following Errors:
ImportError
ModuleNotFoundError: No module named 'modulename'
Well, after having another person look over my code, I realized that I miss-spelled my the import . Ugh... Note to self: change font style and confirm spelling. :). The above sys.path.insert or sys.path.append with import <modulename> works.

Create and run scala code from package in IntelijIDEA

I have the following problem:
Below is the Rational.scala file that has a package name Week_3, which i am trying to import in the scratch.sc file.
But I get an Error:
Object Rational is not a member of package Week_3
Below is the file i am trying to import Rational class.
Anyone knows how can i deal with it?

Importing a local swift module

Swift newbie here, using swift 3 on Linux with the package manager.
I have a package Regulate, executable, and a sibling package Utils, intended to be a library. Utils/Sources has a TextReader.swift file, with class TextReader and its init function both public. The Utils directory is a git repo, described in Regulate/Package.swift:
dependencies: [.Package(url: "../Utils", "1.0.0")]
I've tried 3 ways to instantiate a TextReader object in the Regulate program and gotten 3 error messages:
import Utils
...
let reader = TextReader(filename: name)
error: use of unresolved identifier 'TextReader'
import Utils
...
let reader = Utils.TextReader(filename: name)
error: module 'Utils' has no member named 'TextReader'
import class Utils.TextReader
error: no such decl in module
It looks like the library module needs some additional structure to declare its exports, perhaps.
What do I need to do here? Thanks!
D'oh! This looks like a name conflict.
When I use Utils2 instead of Utils, it works fine. With Utils it cloned and built the other module, but apparently went to some system module instead when I referenced it.

Python module function not defined

I am trying to import a module in my python script and I can't make it work.
So I have my python script: /home/user/pythonscript/oneDir/onescript.py
And I would like to use a script that is a directory higher in hierarchy:
/home/user/pythonscript/common.py
So I did the following at the top of my onescript.py:
import sys
sys.path.insert(1,'/home/user/pythonscript')
import common
In my common.py file, I have a function onecConnect, and when I try to run onescript.py, which uses onecConnect function, I get the following error: nameError: name 'onecConnect' is not defined
Anyone can see what I do wrong or forgot to do?
Thanks
Make sure there are __init__.py in all directories, go to /home/user/pythonscript and run Python code from there. So:
python oneDir/onescript.py
In onescript.py you can do:
from common import onecConnect
The rules are:
Always run a Python script from the highest possible directory (not the deepest into the project).
Always have full import lines, no relative imports.
This keeps the problems away.