A list of puns related to "Module File"
So I'm building a package (named ceres
, for simulating spacecraft dynamics and navigation) that has several submodules to it. (I'm trying to keep a flat hierarchy as per PEP 423). I'll use one of my submodules as an example, the gravity
submodule.
Currently, inside of the gravity
submodule, there are multiple classes you can import: PointMass
, SphericalHarmonic
, Ellipsoid
, Polygon
, etc., all of which are a subclass to an abstract class: GravityField
(which defines abstract methods like get_acceleration
, etc.)
It is currently organized like this:
ceres/
|- gravity/
| - __init__.py
| - gravityfield.py
| - pointmass.py
| - sphericalharmonic.py
| - ...
Where the __init__.py
looks like this (not complete, just to give the gist of things):
from .pointmass import PointMass
from .sphericalharmonic import SphericalHarmonic
.
.
.
This allows you to use to import things in a sensible way (i.e., from ceres.gravity import PointMass
), while still allowing each class definition to have its own separate file (which, I personally, think adds a lot to the readability and organization).
However, a colleague of mine told me that the pythonic way of doing this is to keep all of the classes into a single file, and always keep the __init__.py
completely empty.
I recognize that IDEs allow you to collapse large code blocks, and so file length itself should not be a major consideration in breaking up files. But I still feel like having a single class implementation per file just makes intuitive sense and makes it easier to identify where things are in the file structure. (Other than functions, which I typically declare many to a single .py, as long as they're related)
So am I wrong for feeling this way? Should I restructure my code? This is my first "true" open source project (which I'm using to provide an open-source implementation of my dissertation) so I'd like it to be as professional, clear, and pythonic as possible.
Hi all,
I'm happily using foundry for some months now, have created multiple worlds, not all of which I'm the GM of, and had a lot of fun in general.
One thing though bugs me out. From time to time I upload a picture into the wrong folder, or I want to replace the picture with one of a higher resolution.
I hosted foundry on an RPi4 which I can't access without an hour drive, not even via ssh (company firewall). For the same reason I haven't even updated to v8 yet (running 0.7.9). Not gonna do that without a backup...
Now my question: Is there a module implementing a real file explorer, in which I am allowed to rename or delete files, maybe even only move them?
What are the advantages and disadvantages of splitting your modules into separate interface & implementation files? Ofcourse, splitting helps in better code maintenance and readability but other than that is there any advantage to the compilation times?
As the title says. I have a weird bug. When I drag an actor / item / journal entry to the canvas, or when I move it between folders, nothing happens in Foundry. However, I find small files called '''dropped text.txt''' with the id and type (e.g.)
{"type":"Actor","id":"4KouWUpLqKFqgJet"}
I noticed this last week on foundryVTT 8.9 first, so I updated to 9.242, thinking that maybe the latest version of node.js would solve this. No dice unfortunately.
I dont have this problem on firefox, or on another window using chrome, so the issue is probably in my Chrome browser rather than foundry.
Does anyone else have this issue?
I could downgrade chrome or use a different browser, but I wonder if its just a chrome setting. what would you guys recommend?
I see this folder is typically excluded from uploads. One example is firebase Google web hosting excludes the upload of the node_modules folder. I know we shouldnβt sync that to our git repo as well since itβs not our code. Our full stack web development project has references to this folder inside our HTML pages, so is it best to copy these files outside of this folder into another folder and reference that instead?
I posted this question as well in the course discussion forum.
I'm using Create-React-App for my little project and I'm not really fond of importing class names using
../../default-modules/defaults.module.css in my css files.
I'd like to just import them to my css file like 'default-modules/defaults.module.css
Let's say my folder structure looks like this:
src
| default-modules/
| -- defaults.module.css <-- import and compose selectors from here
| -- buttons.module.css
| components/
| | Card/
| -- index.js
| -- style.module.css <-- file in question
Then, in my nested components' css file, I'm trying to compose from a defaults.module.css that has '.selected' selector:
Card/style.module.css
@import '~default-modules/defaults.module.css' as defaults;
// CssSyntax error: referenced class name "selected" in composes not found (4:2)
.master {
composes: selected from defaults;
}
.childContainer {
display: flex;
flex-direction: row;
gap: 1rem;
align-items: center;
}
Anyway to resolve its path without the relative '../..' hell?
So in a Next.js-project I am currently working on I opted to use the plain old CSS files and the filename.module.css
thing that comes with the Next.js boilerplate.
I added an alias to the styles folder as well so I can
import styles from '@styles/Header.module.css'
rather than
import styles from '../../../../../src/my_documents/../../test/../styles/../../../Header.module.css'
slightly exaggerated. :D
But when I started making components I was thinking if I should put my CSS as a module in the same folder as the component or in the styles folder either as-is or in a components subfolder.
The component: /components/name-of-component/name-of-component.tsx
Option A: /components/name-of-component/name-of-component.module.css
Option B: /styles/name-of-component.module.css
Option C: /styles/components/name-of-component.css
Option D: /styles/name-of-component/name-of-component.css
What do you think and why?
I'm new to VSCode, and I'm coding with Python. I have a small piece of code that imports pandas at the start. When I type Ctrl-Shift-P
and PRINT
(Python: Run file IN Terminal), it runs in a terminal at the bottom, but I get a ModuleNotFoundError
. But when I go to the terminal and type python test.py
, it runs like it should.
Is the PYTHONPATH not automatically set somewhere that I should know about?
I am attaching an uploaded file to email. Easy enough to filter file extensions and file size and sanitize file names, but I'm certain there must be modules that exist to scrutinize files for security? i.e. ensure a .doc is actually a word file, etc.
Hello,
I installed VS 2022 Enterprise, and I noticed that, when I opened an fs file in the editor, it is missing the top bar with the 3 comboboxes where I can select functions or classes. The bar is present when I open a cs file.
Any idea on how to get the bar to show up for fs files?
I also took a look at jetbrains rider dot net and it shows all the modules/submodules/functions in the Structure tool window. Is there an equivalent in VS2019 or VS2022?
Thank you
thanks for your replies. I have thought about these answers and also thought about what I wanted from my original question which was a little vague I suppose.
I guess my main concern is "Is Ansible Declaritive?"
For example with BIND DNS Records/Zone File, if I have something like the following in the role/defaults/main.yml file
cname_vars:
If I run this, this should add these CNAME records to the DNS Zone file, according to the rest of my playbook.
However, if I edit this to:
cname_vars:
Will Ansible remove the CNAME test.example.com
from my DNS Zone File?
---original---
i am not so experienced in the ways of ansible so would like feedback on the following:
I get it, I can use modules that will change my config files, but am wondering if it is the best way....
I have been using ansible a little, and have adopted on using a repo for my system config files. I will change the config as needed in the repo, and then in playbook pull this repo and copy config files as needed and restart services as needed. this let's me keep a repo of all my config files in one place, which I think is a good idea... I don't know if this is what you would call IaC.
Or is this just dumb?
An example for modules in say updating bind? I could have a playbook and keep all my hostnames and records in this playbook, and then I would not need to keep a repo of config files as these playbooks would have variables for all hosts and records. this seems more like IaC.
Please comment, as any insights are likely to be new to me.
How would one scope an override, so typescript doesn't recognize it outside of a specific file.
For example declaring this:
declare module "fastify" {
export interface FastifyInstance {
someSupport(): string;
Β }
}
Inside a something.ts makes typescript autocomplete it everywhere.
What if I want typescript to only override FastifyInstance
inside something.ts
? And everywhere else someSupport is not available?
Hello! I am learning the requests module, and I am trying to figure out how to automatically download the newest version of Optifine for Minecraft. Does anyone know how I would go about doing this?
I have inherited a NodeJS project that we are looking to containerize using Docker. Right now the Node app is running directly on a Raspberry Pi. The problem is that all I have to work with is a huge node_modules directory and no one seems to have the original packages.json file, which is making things extremely difficult. Is it possible to create a packages.json file based on the modules in the node_modules directory and if so what would be the best way to go about this? Any help would be greatly appreciated. Thanks in advance.
I'm trying to get TM to import some modules from a JS file and I'm not having any luck.
Code:
// ==UserScript==
// @name Test-Read-and-Save
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.reddit.com/*
// @grant none
// @license MIT; https://opensource.org/licenses/MIT
// @run-at document-start
// ==/UserScript==
// import the idb-keyval script (for reading/saving data from/to an indexedDB database)
import { get, set, update, createStore } from 'https://cdn.jsdelivr.net/npm/idb-keyval@6/+esm';
// want our own db and store names.
const DBName = 'DbTest';
const DBStore = 'DataStore';
// dummy data
const key = 'JSON';
const values = {'a':true, 'b':false, 'c':true, 'd':true};
// make sure *our* store exists
const store = createStore(DBName, DBStore);
// read the store, if no data, write some ...
let data = await get('JSON', store);
if (!data) {
set(key, JSON.stringify(values), store);
}
In TM, the "import ...;" line, the eslint says: eslint: null - Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
In FireFox, there's an error: Uncaught SyntaxError: import declarations may only appear at top level of a module
In Chrome, there's an error: SyntaxError: Cannot use import statement outside a module
Any ideas on how to get this code to work? (NB: works outside of TM).
I am trying to write a proper CMake script for building an embedded project(STM32). Our project structure looks like this:
App/
....Module1/
....Module2/
Core/
....OwnFramework/
........CoreModule1/
........CoreModule2/
....CubeMXGeneratedCode/
........Core/ (there are more files and dirs, but they are not relevant)
...........Src/main.c (only important info is that main is here)
........Drivers/
....Libs/
........Lib1/ (for example ETL)
Right now there is one CMakeLists.txt file in root project dir, but this seems like a bad solution. I've tried adding CMakeLists into App/ and App/Module but then I would get linking errors (while looking at compile_commands I've seen that they were compiled with almost no flags).
./CMakeLists.txt (removed some non-important parts, like set variables that are obvious, so it's little bit shorter)
set(APP_INCLUDE_DIRECTORIES
${APP_DIR}/Module1
${APP_DIR}/Module2
)
set(CORE_INCLUDE_DIRECTORIES
${Core_DIR}/CoreModule1
${Core_DIR}/CoreModule2
)
set(FLAGS
"-Wl,--gc-sections")
set(CPP_FLAGS
"-fno-rtti -fno-exceptions -fno-threadsafe-statics")
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=hard)
set(STARTUP_SCRIPT ${CUBEMX_DIR}/startup_stm32fxxxxx.s)
set(MCU_LINKER_SCRIPT ${CUBEMX_DIR}/STM32Fxxxxxxx_FLASH.ld)
set(CUBEMX_INCLUDE_DIRECTORIES
${CUBEMX_DIR}/Core/Inc
... and some more Inc dirs
set(PROJECT_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}
${APP_INCLUDE_DIRECTORIES}
${CORE_INCLUDE_DIRECTORIES})
file(GLOB_RECURSE STM32CUBEMX_SOURCES
${CUBEMX_DIR}/Core/*.c
${CUBEMX_DIR}/Drivers/*.c
${CUBEMX_DIR}/Middlewares/Third_Party/FreeRTOS/Source/*.c)
file(GLOB_RECURSE PROJECT_SOURCES FOLLOW_SYMLINKS
${APP_DIR}/*.cpp
${APP_DIR}/*.c
${CORE_DIR}/*.cpp
${CORE_DIR}/*.c)
add_executable(${EXECUTABLE}
${STM32CUBEMX_SOURCES}
${PROJECT_SOURCES}
${STARTUP_SCRIPT})
target_compile_definitions(${EXECUTABLE} PRIVATE
${MCU_
... keep reading on reddit β‘Hello Community,
I've got a bunch of scripts for basic admin tasks and I was wondering if it would be a better idea to group them within a single module.
What should drive this choice ?
Thanks,
Bob
I'm a first year CS student looking to make some personal projects as practice.
Should I create this file?
I did some googling to try and understand what it is, and the best explanation I found is
>"Yes, module-info.java was introduced in Java 9, with the Project Jigsaw module system.
>
>A module is a build artifact (usually a Jar file) that contains a module descriptor that declares the name of the module, what other modules it depends on, what packages it exposes to other modules, and what services it implements.
>
>You see, before Java 9 you had to dump all the libraries your application uses on the classpath, and let Java load all of them to figure out that a class you need is available. The module system allows Java to figure out what module a class is in before it loads the module. That way, only modules that you actually need are loaded, and they're loaded at the time they're needed and no sooner.
>
>There's another even bigger advantage though: Before Java 9, the "public" keyword meant that a class can be accessed by every other class in the entire world. If a class was only intended for internal use in your library and you wanted to hide it from the rest of the world, you had to put it in the same package as all the other library classes that use it and make it package private. Since Java 9, you can make classes public and stick them in different packages of your library, but still hide them from classes outside the library, simply by not exporting the package that the class is in.
>
>When you omit module-info.java, you lose these benefits: your library is loaded regardless of whether and when it is needed, and your public classes are exposes to all the world to see.
>
>It's not a disaster if you don't have a module descriptor, but it's recommended that you add one to every project.
>
>If you don't want to do it now, yes, you can always do it later. e JDK."
That sounds important. Do I have to do anything with this module file, or can I ignore it?
Also, when creating a class in the java project, it says
>"the use of the default package is discouraged"
Is this something i should concern myself with?
I have a project with ~200 hundred files and I wanted to move all of them one level deeper, so that all of my modules become prefixed with the name of the project. This results in me needing to rename all the module names, all the imports of those modules, and then also qualified calls in the code.
Compiler guides me through that but it is a lot of manual work so I wrote a small script that does most of the work for me - it updated module names to reflect their paths and also corrects old imports to use the new name (it doesn't take care of qualified calls though).
Script is pretty naive, in the sense that it uses just regexes and therefore risks false positives, but it actually worked very well for my use case, I had only 2 false positives which I easily fixed. I still needed to do manual work to find those false positives and I needed to correct qualified calls, but it still felt like much less work than without using the script.
Script: https://github.com/wasp-lang/misc/blob/master/hs-fix-modules.hs .
How would you go about this problem, what do you do / use? I tried looking for existing solutions, including retrie, but it didn't seem anything out there supports this kind of refactoring.
If I wanted to make a proper solution that parses the code and looks at AST in order to figure out what needs to be updated -> how would I go about that, where would I start, and is that feasible?
I'm a newb, so forgive me. I'm using babel, webpack, and ES6 modules, so maybe this doesn't really apply to other ways of building TS projects.
At the end of the day, all of the modules in your project are "public" to other parts of your code, anyway (right?). So, grouping stuff in an index.ts doesn't seem to give you the ability to actually hide stuff from the rest of your project in same way that, e.g., Java's package-private concept does.
TypeScript also has issues with cyclic imports (mostly seems to show up when using classes and inheritance) that don't seem to get caught until runtime (yikes!). Adding more layers and ceremony to imports seems like it might make it harder to track down where your imports are actually coming from.
And babel/webpack seems to get upset at re-exporting things that don't exist at runtime (types and interfaces): https://github.com/babel/babel-loader/issues/603. So, you need to be careful to re-export your types with a different syntax, which is hard to remember when you're writing a file full of export * from 'foo'
.
So, is there really any benefit to grouping submodules into index.ts files besides an anal-retentive compulsion to have your imports look pretty within your project?
Or am I just doing stuff wrong? Maybe my project setup sucks. I don't know. But, I wanted to have neat/clean module hierarchies, and I kept getting hit by stupid stuff. Not to mention, I have to remember to add new modules to the corresponding index.ts files or my imports get inconsistent again.
I've developed a strong feeling that I've wasted a good chunk of my time for no benefit at all... :/
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.