Merge pull request #110 from ModOrganizer2/dev/clean-formatting

Formatting (black, isort, clang, line-ending).
This commit is contained in:
Mikaël Capelle
2023-07-10 09:41:54 +02:00
committed by GitHub
15 changed files with 422 additions and 387 deletions
+2
View File
@@ -0,0 +1,2 @@
1bffcfa8bfba93a9505692b11fdd3f0903983542
7108d59267b0fe4e9442f9bb146ea5d70e7704a8
+8
View File
@@ -0,0 +1,8 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text eol=crlf
*.h text eol=crlf
*.py text eol=crlf
+10 -3
View File
@@ -1,9 +1,14 @@
name: Build Plugin Python
on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]
env:
MO_BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
build:
runs-on: windows-2022
@@ -23,7 +28,7 @@ jobs:
key: ${{ runner.OS }}-mob-cache-${{ hashFiles('mob/.git/refs/heads/master') }}
restore-keys: |
${{ runner.OS }}-mob-cache-
- if: ${{ steps.cache-mob.outputs.cache-hit != 'true' }}
- if: steps.cache-mob.outputs.cache-hit != 'true'
name: Build mob
run: .\mob\bootstrap.ps1
- name: Install Qt
@@ -44,7 +49,7 @@ jobs:
key: ${{ runner.OS }}-mo2-dependencies-${{ hashFiles('mob/.git/refs/heads/master') }}
restore-keys: |
${{ runner.OS }}-mo2-dependencies-
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }}
- if: steps.cache-dependencies.outputs.cache-hit != 'true'
name: Build dependencies with mob
run: .\mob\mob.exe
-l 4 -d .
@@ -58,7 +63,9 @@ jobs:
mob.log
# TODO: cache this?
- name: Build cmake_common and uibase
run: .\mob\mob.exe -l 4 -d . build
run: .\mob\mob.exe -l 4 -d .
-s task/mo_fallback=master -s task/mo_branch=${{ env.MO_BRANCH }}
build
--ignore-uncommitted-changes
--redownload --reextract --reconfigure --rebuild
cmake_common uibase
+5
View File
@@ -10,3 +10,8 @@ jobs:
with:
clang-format-version: "15"
check-path: "."
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: isort/isort-action@master
- uses: psf/black@stable
+12
View File
@@ -0,0 +1,12 @@
[flake8]
# Use black line length:
max-line-length = 88
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203, E266
[isort]
profile = black
multi_line_output = 3
known_mobase = mobase
sections=FUTURE,STDLIB,THIRDPARTY,MOBASE,FIRSTPARTY,LOCALFOLDER
+291 -291
View File
File diff suppressed because it is too large Load Diff
+76 -76
View File
@@ -1,76 +1,76 @@
/*
Copyright (C) 2022 Sebastian Herbord & MO2 Team. All rights reserved.
This file is part of python proxy plugin for MO
python proxy plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Python proxy plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROXYPYTHON_H
#define PROXYPYTHON_H
#include <map>
#include <memory>
#include <iplugindiagnose.h>
#include <ipluginproxy.h>
#include <pythonrunner.h>
class ProxyPython : public QObject,
public MOBase::IPluginProxy,
public MOBase::IPluginDiagnose {
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
Q_PLUGIN_METADATA(IID "org.mo2.ProxyPython")
public:
ProxyPython();
virtual bool init(MOBase::IOrganizer* moInfo);
virtual QString name() const override;
virtual QString localizedName() const override;
virtual QString author() const override;
virtual QString description() const override;
virtual MOBase::VersionInfo version() const override;
virtual QList<MOBase::PluginSetting> settings() const override;
QStringList pluginList(const QDir& pluginPath) const override;
QList<QObject*> load(const QString& identifier) override;
void unload(const QString& identifier) override;
public: // IPluginDiagnose
virtual std::vector<unsigned int> activeProblems() const override;
virtual QString shortDescription(unsigned int key) const override;
virtual QString fullDescription(unsigned int key) const override;
virtual bool hasGuidedFix(unsigned int key) const override;
virtual void startGuidedFix(unsigned int key) const override;
private:
MOBase::IOrganizer* m_MOInfo;
HMODULE m_RunnerLib;
std::unique_ptr<mo2::python::IPythonRunner> m_Runner;
enum class FailureType : unsigned int {
NONE = 0,
SEMICOLON = 1,
DLL_NOT_FOUND = 2,
INVALID_DLL = 3,
INITIALIZATION = 4
};
FailureType m_LoadFailure;
};
#endif // PROXYPYTHON_H
/*
Copyright (C) 2022 Sebastian Herbord & MO2 Team. All rights reserved.
This file is part of python proxy plugin for MO
python proxy plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Python proxy plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROXYPYTHON_H
#define PROXYPYTHON_H
#include <map>
#include <memory>
#include <iplugindiagnose.h>
#include <ipluginproxy.h>
#include <pythonrunner.h>
class ProxyPython : public QObject,
public MOBase::IPluginProxy,
public MOBase::IPluginDiagnose {
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
Q_PLUGIN_METADATA(IID "org.mo2.ProxyPython")
public:
ProxyPython();
virtual bool init(MOBase::IOrganizer* moInfo);
virtual QString name() const override;
virtual QString localizedName() const override;
virtual QString author() const override;
virtual QString description() const override;
virtual MOBase::VersionInfo version() const override;
virtual QList<MOBase::PluginSetting> settings() const override;
QStringList pluginList(const QDir& pluginPath) const override;
QList<QObject*> load(const QString& identifier) override;
void unload(const QString& identifier) override;
public: // IPluginDiagnose
virtual std::vector<unsigned int> activeProblems() const override;
virtual QString shortDescription(unsigned int key) const override;
virtual QString fullDescription(unsigned int key) const override;
virtual bool hasGuidedFix(unsigned int key) const override;
virtual void startGuidedFix(unsigned int key) const override;
private:
MOBase::IOrganizer* m_MOInfo;
HMODULE m_RunnerLib;
std::unique_ptr<mo2::python::IPythonRunner> m_Runner;
enum class FailureType : unsigned int {
NONE = 0,
SEMICOLON = 1,
DLL_NOT_FOUND = 2,
INVALID_DLL = 3,
INITIALIZATION = 4
};
FailureType m_LoadFailure;
};
#endif // PROXYPYTHON_H
+6 -6
View File
@@ -1,6 +1,6 @@
#ifndef RESOURCE_H
#define RESOURCE_H
#define IDR_LOADER_DLL 100
#endif // RESOURCE_H
#ifndef RESOURCE_H
#define RESOURCE_H
#define IDR_LOADER_DLL 100
#endif // RESOURCE_H
+2 -1
View File
@@ -1,6 +1,7 @@
import mobase
import pytest
import mobase
m = pytest.importorskip("mobase_tests.argument_wrapper")
+2 -1
View File
@@ -1,6 +1,7 @@
import mobase
import pytest
import mobase
m = pytest.importorskip("mobase_tests.filetree")
+2 -2
View File
@@ -1,11 +1,11 @@
import mobase
import pytest
import mobase
m = pytest.importorskip("mobase_tests.functional")
def test_guessed_string():
# available functions:
# - fn_0_arg, fn_1_arg, fn_2_arg
# - fn_0_or_1_arg, fn_1_or_2_or_3_arg
+2 -2
View File
@@ -1,11 +1,11 @@
import mobase
import pytest
import mobase
m = pytest.importorskip("mobase_tests.guessed_string")
def test_guessed_string():
# empty string
gs = mobase.GuessedString()
+2 -2
View File
@@ -1,13 +1,13 @@
import sys
from pathlib import Path
import mobase
import pytest
from PyQt6.QtCore import QDir, QFileInfo
import mobase
def test_filepath_wrappers():
# TBC that this works everywhere
version = ".".join(map(str, sys.version_info[:3]))
-1
View File
@@ -50,7 +50,6 @@ def test_qdatetime():
def test_qvariant():
# Python -> C++
assert m.qvariant_from_none(None) == (True, False)
+2 -2
View File
@@ -1,8 +1,9 @@
# -*- encoding: utf-8 -*-
import mobase
from PyQt6.QtWidgets import QWidget
import mobase
class DummyModDataChecker(mobase.ModDataChecker):
def dataLooksValid(
@@ -26,7 +27,6 @@ class DummySaveGameInfo(mobase.SaveGameInfo):
# from the C++ side
#
class DummyGame(mobase.IPluginGame):
_features: dict[type, object]
def __init__(self):