ImportError: cannot import name 'test' from 'lib' - python-3.x

as you can see in the picture down below, I created a TEST package, with two sub-packages(test1, test2), this is the structure of the package:
\test
| __pycache__.py # ki importit lib fell main tcrea
| __init__.py
| lib.py
| \test1
| | __init__.py
| | test1.py
| \test2
| | __init__.py
| | test2.py
I wanted to import lib inside test1.py
I have tried the next code( as I sawed in the tutorials):
import lib
lib.test()
# from lib import test
# test()
# from ..lib import test
# test()
I tried to execute the code with vs code cmd from the TEST package then I entered to test1 sub-package(cd .\test1) to try but it didn't work.
I got those errors:
THANKS FOR HELP!!

Related

ReferenceError: json2html is not defined in jest test using ts-jest

I am trying to use node-jsdom2html module from within jest test, but I am getting this error:
ReferenceError: json2html is not defined
1 | import generateReport from "../report-generator";
> 2 | import * as jsontohtml from '../../node_modules/node-json2html/node.json2html'
| ^
3 | import {
4 | fullConfig,
5 | fullResult,
at Object.<anonymous> (node_modules/node-json2html/node.json2html.js:18:18)
at Object.<anonymous> (src/__tests__/index.spec.ts:2:1)
I did a demo repository with the code I am trying to execute and I am facing the error:
https://github.com/cunhabruno/jest-bug-node-json2html/blob/main/__tests__/demo.spec.ts

How can I reference cousin objects in scons?

How can I get objects that are built under separate SConscripts in my program correctly? I have a directory structure that looks similar to this:
SConstruct
|
|---- moduleA
| |
| ----Sconscript
| ----src
| |-- sourceA1.cpp
| |-- sourceA2.cpp
| ----build
| |-- sourceA1.o
| |-- sourceA2.o
|
|---- moduleB
| |
| ----Sconscript
| ----src
| |-- sourceB1.cpp
| |-- sourceB2.cpp
| ----build
| |-- sourceB1.o
| |-- sourceB2.o
|
|---- Program
|
----SConscript
----src
| -- main.cpp
moduleA's SConscript might look like this (moduleB is similar):
moduleEnv = env.Clone()
srcFiles = [ 'src/sourceA1.cpp', 'src/sourceA2.cpp' ]
obj = moduleEnv.Object(srcFiles)
In my Program, I need to use the object files to build. I don't want to use a bunch of hard coded paths to do this. Is there any way that the SConscript for the program can reference the objects of the modules?
Program's SConscript
progEnv = env.Clone()
objectsList = [ Objects from the modules ] # Is this possible, or is the a better way?
prog = progEnv.Program('myprogram', [ objectList, 'src/main.cpp'])
Any variable you define in an SConscript can be Export()ed so other SConscripts can pick it up (via Import()). The export space is global. In your example for moduleA's SConscript, after the call to Object, obj holds a list of Nodes (even though in the majority of cases that list has only one entry - here it would be two). A node is SCons' internal representation of an object participating in the build, and it's prefectly fine to use those to refer to built objects - and means you shouldn't have path problems, because SCons always knows how to locate a node. You can collect those and export them. I would probably do one per module, so perhaps:
obj = moduleEnv.Object(srcFiles)
moduleEnv.Export(moduleAobj=obj)
Then your main SConscript can look like:
SConscript("moduleA/SConscript")
Import("moduleAobj")
SConscript("moduleB/SConscript")
Import("moduleBobj")
objects = Flatten([moduleAobj, moduleBobj])
that's untested but hopefully a starting point, at least.

pywinatuo - Access Database Match Error for the same property - Code works on a small database not on a large one

I am trying to run some access queries using pywinauto. The error Constantly changes.
After checking the control properties i found that the query name does exist. However the the code throws an error stating match not found.
import os
import subprocess
access_file = r'C:\Ren'
filename='test.accdb'
accessPath = 'C:\Program Files (x86)\Microsoft Office\Office15\MSACCESS.exe'
subprocess.Popen([accessPath,access_open])
dlg=Desktop(backend='uia').window(title_re='Access*')
sleep(10)
dlg.Navigation_Pane.Queries.Query1.invoke()
dlg.Yes.invoke()
print(dlg.print_control_identifiers())
This code works on a smaller database. I Tried it 1st on a large database and got errors so i created a test database with few tables and queries. It works fine.
When i change dlg.Navigation_Pane.Queries.delete_reports.invoke()
and change the path to the actual database. I get a MatchError: Could not find 'Queries'.
This is the control properties.
GroupBox - 'Queries' (L4, T2979, R429, B5581)
| | | | ['Queries', 'QueriesGroupBox', 'GroupBox8', 'Queries0', 'Queries1']
| | | | child_window(title="Queries", control_type="Group")
Button - 'delete report' (L4, T3271, R429, B3301)
| | | | | ['Button147', 'delete reportButton', 'delete report']
| | | | | child_window(title="delete report", control_type="Button")
I am unable to understand why does it one work on one database and does not on the other.
Regards,
Ren.

Can't import .lhs script in Haskell

I have two files, S5.hs and S6.lhs, in the same folder, and I want to import the S6.lhs script in S5.hs, but when i type import S6, i get:
Could not find module `S6'
Use -v to see a list of the files searched for.
|
1 | import S6
| ^^^^^^^^^^
Failed, no modules loaded.
When I lauch it from the folder, I get following message(the first line of the S6 file is import Data.Array):
File name does not match module name:
Saw: `Main'
Expected: `S6'
|
1 | import Data.List
| ^
Why is this happening?
Looks like you need to specify at the top of the S6.lhs file that you want this file to be treated as the S6 module, as opposed to the default module name of Main. You would do that with module S6 where or module S6 (export, list) where.

You may need an appropriate loader to handle this file - .net core & Angular

I keep getting the following error web running a production build of a .net core angular 4 application. Those are 2 node packages I installed and looks like their is some issue with webpack reading those files only for production builds. Any thoughts?
ERROR in ./$$_gendir/~/ngx-mydatepicker/dist/ngx-my-date-picker.component.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-mydatepicker\dist\ngx-my-date-picker.component.ngfactory.ts Unexpected token (14:28)
You may need an appropriate loader to handle this file type.
| import * as i3 from 'ngx-mydatepicker/dist/directives/ngx-my-date-picker.focus.directive';
| import * as i4 from 'ngx-mydatepicker/dist/services/ngx-my-date-picker.util.service';
| const styles_NgxMyDatePicker:any[] = ['.ngxmdp .headertodaybtn,.ngxmdp .monthcell,.ngxmdp .weekdaytitle{overflow:hidden;white-space:nowrap}.ngxmdp *{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:Arial,Helvetica,sans-serif;padding:0;margin:0}.ngxmdp .selector{position:absolute;padding:0;border:1px solid #CCC;border-radius:4px;z-index:100000;animation:selectorfadein 60ms}.ngxmdp .selector:focus{border:1px solid #ADD8E6;outline:0}#keyframes selectorfadein{from{opacity:0}to{opacity:1}}.ngxmdp .selectorarrow{background:#FAFAFA;padding:0}.ngxmdp .selectorarrow:after,.ngxmdp .selectorarrow:before{bottom:100%;border:solid transparent;content:" ";height:0;width:0;position:absolute}.ngxmdp .selectorarrow:after{border-color:rgba(250,250,250,0);border-bottom-color:#FAFAFA;border-width:10px;margin-left:-10px}.ngxmdp .selectorarrow:before{border-color:rgba(204,204,204,0);border-bottom-color:#CCC;border-width:11px;margin-left:-11px}.ngxmdp .selectorarrow:focus:before{bord...
| export const RenderType_NgxMyDatePicker:i0.RendererType2 = i0.ɵcrt({encapsulation:2,
| styles:styles_NgxMyDatePicker,data:{}});
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts 10:0-115
# ./ClientApp/boot.server.ts
ERROR in ./$$_gendir/~/ngx-loading/ngx-loading.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-loading\ngx-loading.ngfactory.ts Unexpected token (12:35)
You may need an appropriate loader to handle this file type.
| import * as i1 from 'ngx-loading';
| import * as i2 from '#angular/common';
| export const LoadingModuleNgFactory:i0.NgModuleFactory<i1.LoadingModule> = i0.ɵcmf(i1.LoadingModule,
| ([] as any[]),(_l:any) => {
| return i0.ɵmod([i0.ɵmpd(512,i0.ComponentFactoryResolver,i0.ɵCodegenComponentFactoryResolver,
# ./$$_gendir/ClientApp/app/components/app/app.component.ngfactory.ts 9:0-94
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts
# ./ClientApp/boot.server.ts
I found the solution here https://github.com/aspnet/JavaScriptServices/issues/1168#issuecomment-320026397
Just needed to remove include: /ClientApp/ from myh webpack.config.js.

Resources